| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- using System;
- using System.Collections.Generic;
- using System.Common;
- using System.IRepositories;
- using System.Linq;
- using System.Model;
- using System.Security.Claims;
- using System.Threading.Tasks;
- using Microsoft.AspNetCore.Authorization;
- using Microsoft.AspNetCore.Mvc;
- using SqlSugar;
- // For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
- namespace TVShoppingCallCenter_ZLJ.Controllers.Customer
- {
- [Authorize]
- [Produces("application/json")]
- [Route("api/[controller]")]
- public class CusMsgController : BaseController
- {
- private readonly ICus_MsgRepository _cus_msgRepository;
- public CusMsgController(ICus_MsgRepository cus_msgRepository)
- {
- _cus_msgRepository = cus_msgRepository;
- }
- [HttpGet]
- public IActionResult Index()
- {
- return Success("成功");
- }
- /// <summary>
- /// 添加消息提醒
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [HttpPost("add")]
- public async Task<IActionResult> AddAsync(int type, int vipid, string toperson, string notifyperson,string notice)
- {
- var model = new T_Cus_Msg();
- model.F_Type = 1;
- model.F_VipInfoID = vipid;
- model.F_ToPerson = toperson;
- model.F_State = 0;
- model.F_Notice = notice;
- model.F_NotifyPerson = notifyperson;
- model.F_CreateBy = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value;
- model.F_CreateOn = DateTime.Now;
- var res = await _cus_msgRepository.Add(model);
- if (res > 0)
- {
- return Success("添加成功");
- }
- else
- {
- return Error("添加失败");
- }
- }
- /// <summary>
- /// 获取列表分页
- /// </summary>
- /// <param name="keyword"></param>
- /// <param name="pageindex"></param>
- /// <param name="pagesize"></param>
- /// <returns></returns>
- [HttpGet("getlistbypage")]
- public async Task<IActionResult> GetListsByPageAsync(int state,string tousercode, string fromusercode, int type,int pageindex = 1, int pagesize = 20)//state传0时获取全部,传1时获取未处理,传2时获取已处理
- {
- List<IConditionalModel> conModels = new List<IConditionalModel>();
- #region 条件筛选
- if (state == 1)
- {
- //conModels.Add(new ConditionalModel() { FieldName = "F_State", ConditionalType = ConditionalType.Equal, FieldValue = state.ToString() });
- conModels.Add(new ConditionalCollections()
- {
- ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>()
- {
- new KeyValuePair<WhereType, ConditionalModel>(WhereType.And, new ConditionalModel() { FieldName = "F_State", ConditionalType = ConditionalType.Equal, FieldValue = "0" }),
- new KeyValuePair<WhereType, ConditionalModel>( WhereType.Or , new ConditionalModel() { FieldName = "F_State", ConditionalType = ConditionalType.Equal, FieldValue = "1" })
- }
- });
- }
- else if (state == 2)
- {
- conModels.Add(new ConditionalCollections()
- {
- ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>()
- {
- new KeyValuePair<WhereType, ConditionalModel>(WhereType.And, new ConditionalModel() { FieldName = "F_State", ConditionalType = ConditionalType.Equal, FieldValue = "2" }),
- new KeyValuePair<WhereType, ConditionalModel>( WhereType.Or , new ConditionalModel() { FieldName = "F_State", ConditionalType = ConditionalType.Equal, FieldValue = "3" })
- }
- });
- }
- if (!string.IsNullOrEmpty(tousercode))
- {
- conModels.Add(new ConditionalModel() { FieldName = "F_ToPerson", ConditionalType = ConditionalType.Like , FieldValue = tousercode });
- }
- if (!string.IsNullOrEmpty(fromusercode))
- {
- conModels.Add(new ConditionalModel() { FieldName = "F_CreateBy", ConditionalType = ConditionalType.Like, FieldValue = fromusercode });
- }
- //if (!string.IsNullOrEmpty(keyword))
- //{
- // conModels.Add(new ConditionalModel() { FieldName = "F_Name", ConditionalType = ConditionalType.Like, FieldValue = keyword });
- //}
-
- #endregion
- int recordCount = 0;
- var list = await _cus_msgRepository.GetListByPage(conModels, new MyPageModel() { PageIndex = pageindex, PageSize = pagesize, PageCount = recordCount });
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = list,
- total = recordCount,
- };
- return Content(obj.ToJson());
- }
- /// <summary>
- /// 获取转移消息详情
- /// </summary>
- /// <param name="id">id</param>
- /// <returns></returns>
- [HttpGet("getdetails")]
- public async Task<IActionResult> GetDetailsAsync(int id)
- {
- if (id <= 0)
- return Error("参数错误");
- var model = await _cus_msgRepository.GetSingle(x => x.F_ID == id);
- if (model == null)
- {
- return Error("获取失败");
- }
- return Success("获取成功!", model);
- }
- }
- }
|