using Microsoft.AspNetCore.Mvc;
using Nirvana.Common.ApiBase;
using YBDevice.NApi.Application.MessageInfo;

namespace YBDevice.NApi.Controllers.Api
{
    /// <summary>
    /// 消息管理
    /// </summary>
    public class MessageController : BaseController
    {
        private readonly IMessageService _messageService;
        public MessageController(IMessageService messageService)
        {
            _messageService = messageService;
        }
        /// <summary>
        /// 获取消息模板列表
        /// </summary>
        /// <param name="appid">小程序appid</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ResultInfo> GetTplListAsync(string appid)
        {
            return await _messageService.GetTplListAsync(appid);
        }
        /// <summary>
        /// 消息订阅
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> SubscribeAsync([FromBody] SubscribeC2SDto data)
        {
            return await _messageService.SubscribeAsync(data);
        }
        /// <summary>
        /// 获取订阅状态
        /// </summary>
        /// <param name="appid">小程序appid</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ResultInfo> GetSubscribeInfoAsync(string appid)
        {
            return await _messageService.GetSubscribeInfoAsync(appid);
        }
        /// <summary>
        /// 消息取消订阅
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> UnSubscribeAsync(UnSubscribeC2SDto data)
        {
            return await _messageService.UnSubscribeAsync(data);
        }
        /// <summary>
        /// 获取客服配置信息
        /// </summary>
        /// <param name="appid">小程序appid</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ResultInfo> GetServiceInfoAsync(string appid)
        {
            return await _messageService.GetServiceInfoAsync(appid);
        }
    }
}
