足力健后端,使用.netcore版本,合并1个项目使用

ChatLogController.cs 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Common;
  4. using System.IRepositories.Bus;
  5. using System.Linq;
  6. using System.Model.Bus;
  7. using System.Threading.Tasks;
  8. using Microsoft.AspNetCore.Mvc;
  9. using SqlSugar;
  10. namespace TVShoppingCallCenter_ZLJ.Controllers.Order
  11. {
  12. [Produces("application/json")]
  13. [Route("api/[controller]")]
  14. public class ChatLogController : BaseController
  15. {
  16. private readonly IBus_ChatLogRepository bus_ChatLogRepository;
  17. public ChatLogController(IBus_ChatLogRepository _bus_ChatLogRepository
  18. )
  19. {
  20. bus_ChatLogRepository = _bus_ChatLogRepository;
  21. }
  22. /// <summary>
  23. /// 添加
  24. /// </summary>
  25. /// <param name="input"></param>
  26. /// <returns></returns>
  27. [HttpPost("add")]
  28. public async Task<IActionResult> AddAsync(T_Bus_ChatLog input)
  29. {
  30. if (string.IsNullOrEmpty(input.F_Content ))
  31. return Error("请输入备注内容");
  32. // if (string.IsNullOrEmpty(input.F_WoID))
  33. // return Error("请选择工单");
  34. input.F_AddTime = DateTime.Now;
  35. input.F_AddUser = UserLogin.UserId;
  36. input.F_AddUserName = UserLogin.UserName;
  37. input.F_IsDelete = 0;
  38. if (await bus_ChatLogRepository.Add(input) > 0)
  39. {
  40. return Success("添加成功");
  41. }
  42. return Error("添加失败");
  43. }
  44. /// <summary>
  45. /// 修改
  46. /// </summary>
  47. /// <param name="input"></param>
  48. /// <returns></returns>
  49. [HttpPost("update")]
  50. public async Task<IActionResult> updateAsync(T_Bus_ChatLog input)
  51. {
  52. if (string.IsNullOrEmpty(input.F_Content))
  53. return Error("请输入备注内容");
  54. if (string.IsNullOrEmpty(input.F_WoID))
  55. return Error("参数错误");
  56. if (input.F_ID <= 0)
  57. return Error("参数错误");
  58. var model = await bus_ChatLogRepository.GetSingle(x => x.F_ID == input.F_ID);
  59. if (model == null)
  60. return Error("参数错误");
  61. input.F_State = model.F_State;
  62. input.F_UpdateTime = DateTime.Now;
  63. input.F_UpdateUser = UserLogin.UserId;
  64. input.F_UpdateUserName = UserLogin.UserName;
  65. input.F_IsDelete = model .F_IsDelete ;
  66. input.F_AddTime = model.F_AddTime;
  67. input.F_AddUser = model.F_AddUser;
  68. input.F_AddUserName = model.F_AddUserName;
  69. if (await bus_ChatLogRepository.Update(model))
  70. {
  71. return Success("修改成功");
  72. }
  73. return Error("修改失败");
  74. }
  75. /// <summary>
  76. /// 删除
  77. /// </summary>
  78. /// <param name="ids"></param>
  79. /// <returns></returns>
  80. [HttpPost("delete")]
  81. public async Task<IActionResult> Remove(string orderids)
  82. {
  83. List<T_Bus_ChatLog> modellist = new List<T_Bus_ChatLog>();
  84. var res = 0;
  85. string[] ids = orderids.Split(',');
  86. if (ids != null && ids.Length > 0)
  87. {
  88. try
  89. {
  90. foreach (var item in ids)
  91. {
  92. var model = await bus_ChatLogRepository.GetSingle(x => x.F_ID == int.Parse(item));
  93. model.F_IsDelete =1;
  94. modellist.Add(model);
  95. }
  96. }
  97. catch
  98. {
  99. return Error("删除失败");
  100. }
  101. if (modellist != null && modellist.Count > 0)
  102. {
  103. if (await bus_ChatLogRepository.UpdateListToColumns(modellist, s => new { s.F_IsDelete }))
  104. {
  105. return Success("成功");
  106. }
  107. }
  108. else
  109. {
  110. return Success("内容为空");
  111. }
  112. }
  113. return Error("删除失败");
  114. }
  115. /// <summary>
  116. /// 获取列表
  117. /// </summary>
  118. /// <param name="keyword"></param>
  119. /// <param name="pageindex"></param>
  120. /// <param name="pagesize"></param>
  121. /// <returns></returns>
  122. [HttpGet("getlist")]
  123. public async Task<IActionResult> GetLisAsync(string woid , int state = 1, int pageindex = 1, int pagesize = 20)
  124. {
  125. List<IConditionalModel> conModels = new List<IConditionalModel>();
  126. #region 条件筛选
  127. conModels.Add(new ConditionalModel() { FieldName = "F_State", ConditionalType = ConditionalType.Equal , FieldValue = state.ToString() });
  128. conModels.Add(new ConditionalModel() { FieldName = "F_WoID", ConditionalType = ConditionalType.Equal, FieldValue = woid.ToString() });
  129. conModels.Add(new ConditionalCollections()
  130. {
  131. ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>()
  132. {
  133. new KeyValuePair<WhereType, ConditionalModel>(WhereType.And, new ConditionalModel() { FieldName = "F_IsSo", ConditionalType = ConditionalType.Equal , FieldValue = "1"}),
  134. new KeyValuePair<WhereType, ConditionalModel>( WhereType.Or , new ConditionalModel() { FieldName = "F_AddUser", ConditionalType = ConditionalType.Like, FieldValue = UserLogin.UserId }),
  135. }
  136. });
  137. #endregion
  138. int recordCount = 0;
  139. var list = await bus_ChatLogRepository.GetListByPage(conModels, new MyPageModel() { PageIndex = pageindex, PageSize = pagesize, PageCount = recordCount }, "F_AddTime desc");
  140. var obj = new
  141. {
  142. state = "success",
  143. message = "成功",
  144. rows = list,
  145. total = list.Totals,
  146. };
  147. return Content(obj.ToJson());
  148. }
  149. }
  150. }