人民医院API

DictionaryController.cs 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. using RMYY_CallCenter_Api.Utility;
  2. using CallCenterApi.Interface.Models;
  3. using RMYY_CallCenter_Api.Controllers;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Web;
  10. using System.Web.Mvc;
  11. using RMYY_CallCenter_Api.Model;
  12. using RMYY_CallCenter_Api.Models;
  13. namespace RMYY_CallCenter_Api.Controllers
  14. {
  15. public class DictionaryController : BaseController
  16. {
  17. private RMYY_CallCenter_Api.Bll.T_Sys_DictionaryBase dictionaryBaseBLL = new RMYY_CallCenter_Api.Bll.T_Sys_DictionaryBase();
  18. private RMYY_CallCenter_Api.Bll.T_Sys_DictionaryValue dictionaryValueBLL = new RMYY_CallCenter_Api.Bll.T_Sys_DictionaryValue();
  19. #region 字典操作
  20. /// <summary>
  21. /// 获取字典列表
  22. /// </summary>
  23. /// <returns></returns>
  24. public ActionResult GetList(FilterDictionary filter)
  25. {
  26. var sql = " and F_State=1 ";
  27. var recordCount = 0;
  28. var dt = RMYY_CallCenter_Api.Bll.PagerBll.GetListPager(
  29. "T_Sys_DictionaryBase",
  30. "F_DictionaryFlag",
  31. "*",
  32. sql,
  33. "ORDER BY F_Sort ",
  34. filter.PageSize,
  35. filter.PageIndex,
  36. true,
  37. out recordCount);
  38. List<T_Sys_DictionaryBase> modelList = dictionaryBaseBLL.DataTableToList(dt);
  39. var obj = new
  40. {
  41. rows = modelList.Select(x => new
  42. {
  43. name = x.F_DictionaryName,
  44. flag = x.F_DictionaryFlag,
  45. sort = x.F_Sort
  46. }),
  47. total = recordCount
  48. };
  49. return Content(obj.ToJson());
  50. }
  51. /// <summary>
  52. /// 获取字典
  53. /// </summary>
  54. /// <param name="dicFlag"></param>
  55. /// <returns></returns>
  56. public ActionResult GetDic(string dicFlag)
  57. {
  58. T_Sys_DictionaryBase baseModel = dictionaryBaseBLL.GetModel(dicFlag);
  59. if (baseModel != null)
  60. return Success("加载字典成功", new
  61. {
  62. name = baseModel.F_DictionaryName,
  63. flag = baseModel.F_DictionaryFlag,
  64. sort = baseModel.F_Sort
  65. });
  66. else
  67. return Error("加载字典失败");
  68. }
  69. //[Authority]
  70. /// <summary>
  71. /// 添加字典
  72. /// </summary>
  73. /// <param name="input"></param>
  74. /// <returns></returns>
  75. public ActionResult AddDic(DictionaryBaseInput input)
  76. {
  77. T_Sys_DictionaryBase orderModel = new T_Sys_DictionaryBase();
  78. var model = dictionaryBaseBLL.GetModel(input.DicFlag.Trim());
  79. if (model != null)
  80. return Error("字典标志已存在");
  81. orderModel.F_DictionaryFlag = input.DicFlag;
  82. orderModel.F_DictionaryName = input.Name;
  83. orderModel.F_Describe = input.Remark;
  84. orderModel.F_State = true;
  85. orderModel.F_Sort = input.Sort;
  86. if (dictionaryBaseBLL.Add(orderModel))
  87. return Success("字典添加成功");
  88. else
  89. return Error("字典添加失败");
  90. }
  91. //[Authority]
  92. /// <summary>
  93. /// 编辑字典
  94. /// </summary>
  95. /// <param name="input"></param>
  96. /// <returns></returns>
  97. public ActionResult EditDic(DictionaryBaseInput input)
  98. {
  99. T_Sys_DictionaryBase orderModel = dictionaryBaseBLL.GetModel(input.DicFlag.Trim());
  100. if (orderModel == null)
  101. return Error("字典对象不存在");
  102. orderModel.F_DictionaryFlag = input.DicFlag;
  103. orderModel.F_DictionaryName = input.Name;
  104. orderModel.F_Describe = input.Remark;
  105. orderModel.F_Sort = input.Sort;
  106. if (dictionaryBaseBLL.Update(orderModel))
  107. return Success("字典添加成功");
  108. else
  109. return Error("字典添加失败");
  110. }
  111. //[Authority]
  112. /// <summary>
  113. /// 删除字典
  114. /// </summary>
  115. /// <param name="ids"></param>
  116. /// <returns></returns>
  117. public ActionResult DelDic(string[] ids)
  118. {
  119. if (ids == null || ids.Length <= 0)
  120. return Error("获取参数失败");
  121. StringBuilder sb = new StringBuilder();
  122. foreach (var item in ids)
  123. {
  124. sb.Append("'" + item + "',");
  125. }
  126. if (dictionaryBaseBLL.DeleteList(sb.ToString().Trim(',')))
  127. return Success("删除成功");
  128. else
  129. return Error("删除失败");
  130. }
  131. #endregion
  132. #region 字典值操作
  133. //获取字典值列表
  134. public ActionResult GetDicValueList(FilterDictionary filter)
  135. {
  136. string sql = "";
  137. DataTable dt = new DataTable();
  138. if (!string.IsNullOrWhiteSpace(filter.Id))
  139. {
  140. sql += " and F_DictionaryFlag= '" + filter.Id + "' ";
  141. }
  142. if (!string.IsNullOrWhiteSpace(filter.Flag))
  143. {
  144. sql += " and F_DictionaryFlag like '%" + filter.Flag + "%' ";
  145. }
  146. if (!string.IsNullOrWhiteSpace(filter.Name))
  147. {
  148. sql += " and F_Name like '%" + filter.Name + "%' ";
  149. }
  150. int recordCount = 0;
  151. dt = RMYY_CallCenter_Api.Bll.PagerBll.GetListPager(
  152. "T_Sys_DictionaryValue",
  153. "F_DictionaryValueId",
  154. "*",
  155. sql,
  156. "ORDER BY F_Sort ",
  157. filter.PageSize,
  158. filter.PageIndex,
  159. true,
  160. out recordCount);
  161. List<T_Sys_DictionaryValue> modelList = dictionaryValueBLL.DataTableToList(dt);
  162. var obj = new
  163. {
  164. rows = dt,
  165. total = recordCount
  166. };
  167. return Content(obj.ToJson());
  168. }
  169. //获取字典值列表
  170. public ActionResult GetDicValueListByFlag(string flag)
  171. {
  172. DataTable dt = new DataTable();
  173. dt = dictionaryValueBLL.GetList(" F_DictionaryFlag='" + flag + "' and F_State=1 ").Tables[0];
  174. return Success("列表加载成功", dt);
  175. }
  176. //加载字典值
  177. public ActionResult GetDicValue(int dicValueId = 0)
  178. {
  179. if (dicValueId <= 0)
  180. return Error("字典值标识传输失败");
  181. T_Sys_DictionaryValue valueModel = dictionaryValueBLL.GetModel(dicValueId);
  182. if (valueModel != null)
  183. return Success("加载字典值成功", new
  184. {
  185. id = valueModel.F_DictionaryValueId,
  186. dicflag = valueModel.F_DictionaryFlag,
  187. name = valueModel.F_Name,
  188. remark = valueModel.F_Describe,
  189. sort = valueModel.F_Sort,
  190. });
  191. else
  192. return Error("加载字典值失败");
  193. }
  194. //[Authority]
  195. //添加字典值
  196. public ActionResult AddDicValue(DictionaryValueInput input)
  197. {
  198. T_Sys_DictionaryValue orderModel = new T_Sys_DictionaryValue();
  199. orderModel.F_Name = input.DicvName;
  200. orderModel.F_Describe = input.DicDes;
  201. orderModel.F_State = true;
  202. orderModel.F_ValueCode = "";
  203. orderModel.F_DictionaryFlag = input.DicFlag;
  204. orderModel.F_Sort = input.Sort;
  205. if (dictionaryValueBLL.Add(orderModel) > 0)
  206. return Success("字典值添加成功");
  207. else
  208. return Error("字典值添加失败");
  209. }
  210. ////[Authority]
  211. //编辑字典值
  212. public ActionResult EditDicValue(DictionaryValueInput input)
  213. {
  214. if (input.DicVid <= 0)
  215. return Error("字典值id获取失败");
  216. T_Sys_DictionaryValue orderModel = dictionaryValueBLL.GetModel(input.DicVid);
  217. if (orderModel == null)
  218. return Error("字典值对象获取失败");
  219. orderModel.F_Name = input.DicvName;
  220. orderModel.F_Describe = input.DicDes;
  221. orderModel.F_ValueCode = "";
  222. orderModel.F_DictionaryFlag = input.DicFlag;
  223. orderModel.F_Sort = input.Sort;
  224. if (dictionaryValueBLL.Update(orderModel))
  225. return Success("字典值编辑成功");
  226. else
  227. return Error("字典值编辑失败");
  228. }
  229. //[Authority]
  230. //删除字典值
  231. public ActionResult DelDicValue(string[] ids)
  232. {
  233. if (ids == null || ids.Length <= 0)
  234. return Error("获取参数失败");
  235. var idStr = string.Join(",", ids);
  236. if (dictionaryValueBLL.DeleteList(idStr))
  237. return Success("删除成功");
  238. else
  239. return Error("删除失败");
  240. }
  241. #endregion
  242. #region 微信端字典
  243. /// <summary>
  244. /// 获取字典值列表 - 微信端使用
  245. /// </summary>
  246. /// <param name="flag"></param>
  247. /// <returns></returns>
  248. public ActionResult GetDicValueListByFlagWx(string flag)
  249. {
  250. DataTable dt = new DataTable();
  251. dt = dictionaryValueBLL.GetList(" F_DictionaryFlag='" + flag + "' and F_State=1 ").Tables[0];
  252. return Success("列表加载成功", dt);
  253. }
  254. #endregion
  255. }
  256. }