| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- using System;
- using System.Collections.Generic;
- using System.Common;
- using System.IRepositories.Bus;
- using System.Linq;
- using System.Model.Bus;
- using System.Threading.Tasks;
- using Microsoft.AspNetCore.Mvc;
- using SqlSugar;
- namespace TVShoppingCallCenter_ZLJ.Controllers.Order
- {
-
- [Produces("application/json")]
- [Route("api/[controller]")]
- public class ChatLogController : BaseController
- {
- private readonly IBus_ChatLogRepository bus_ChatLogRepository;
- public ChatLogController(IBus_ChatLogRepository _bus_ChatLogRepository
- )
- {
- bus_ChatLogRepository = _bus_ChatLogRepository;
- }
- /// <summary>
- /// 添加
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [HttpPost("add")]
- public async Task<IActionResult> AddAsync(T_Bus_ChatLog input)
- {
- if (string.IsNullOrEmpty(input.F_Content ))
- return Error("请输入备注内容");
- // if (string.IsNullOrEmpty(input.F_WoID))
- // return Error("请选择工单");
- input.F_AddTime = DateTime.Now;
- input.F_AddUser = UserLogin.UserId;
- input.F_AddUserName = UserLogin.UserName;
-
- input.F_IsDelete = 0;
- if (await bus_ChatLogRepository.Add(input) > 0)
- {
- return Success("添加成功");
- }
- return Error("添加失败");
- }
- /// <summary>
- /// 修改
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [HttpPost("update")]
- public async Task<IActionResult> updateAsync(T_Bus_ChatLog input)
- {
- if (string.IsNullOrEmpty(input.F_Content))
- return Error("请输入备注内容");
- if (string.IsNullOrEmpty(input.F_WoID))
- return Error("参数错误");
- if (input.F_ID <= 0)
- return Error("参数错误");
- var model = await bus_ChatLogRepository.GetSingle(x => x.F_ID == input.F_ID);
- if (model == null)
- return Error("参数错误");
- input.F_State = model.F_State;
- input.F_UpdateTime = DateTime.Now;
- input.F_UpdateUser = UserLogin.UserId;
- input.F_UpdateUserName = UserLogin.UserName;
- input.F_IsDelete = model .F_IsDelete ;
- input.F_AddTime = model.F_AddTime;
- input.F_AddUser = model.F_AddUser;
- input.F_AddUserName = model.F_AddUserName;
- if (await bus_ChatLogRepository.Update(model))
- {
- return Success("修改成功");
- }
- return Error("修改失败");
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="ids"></param>
- /// <returns></returns>
- [HttpPost("delete")]
- public async Task<IActionResult> Remove(string orderids)
- {
- List<T_Bus_ChatLog> modellist = new List<T_Bus_ChatLog>();
- var res = 0;
- string[] ids = orderids.Split(',');
- if (ids != null && ids.Length > 0)
- {
- try
- {
- foreach (var item in ids)
- {
- var model = await bus_ChatLogRepository.GetSingle(x => x.F_ID == int.Parse(item));
- model.F_IsDelete =1;
- modellist.Add(model);
- }
- }
- catch
- {
- return Error("删除失败");
- }
- if (modellist != null && modellist.Count > 0)
- {
- if (await bus_ChatLogRepository.UpdateListToColumns(modellist, s => new { s.F_IsDelete }))
- {
- return Success("成功");
- }
- }
- else
- {
- return Success("内容为空");
- }
- }
- return Error("删除失败");
- }
- /// <summary>
- /// 获取列表
- /// </summary>
- /// <param name="keyword"></param>
- /// <param name="pageindex"></param>
- /// <param name="pagesize"></param>
- /// <returns></returns>
- [HttpGet("getlist")]
- public async Task<IActionResult> GetLisAsync(string woid , int state = 1, int pageindex = 1, int pagesize = 20)
- {
- List<IConditionalModel> conModels = new List<IConditionalModel>();
- #region 条件筛选
- conModels.Add(new ConditionalModel() { FieldName = "F_State", ConditionalType = ConditionalType.Equal , FieldValue = state.ToString() });
- conModels.Add(new ConditionalModel() { FieldName = "F_WoID", ConditionalType = ConditionalType.Equal, FieldValue = woid.ToString() });
- conModels.Add(new ConditionalCollections()
- {
- ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>()
- {
- new KeyValuePair<WhereType, ConditionalModel>(WhereType.And, new ConditionalModel() { FieldName = "F_IsSo", ConditionalType = ConditionalType.Equal , FieldValue = "1"}),
- new KeyValuePair<WhereType, ConditionalModel>( WhereType.Or , new ConditionalModel() { FieldName = "F_AddUser", ConditionalType = ConditionalType.Like, FieldValue = UserLogin.UserId }),
- }
- });
- #endregion
- int recordCount = 0;
- var list = await bus_ChatLogRepository.GetListByPage(conModels, new MyPageModel() { PageIndex = pageindex, PageSize = pagesize, PageCount = recordCount }, "F_AddTime desc");
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = list,
- total = list.Totals,
- };
- return Content(obj.ToJson());
- }
- }
- }
|