/***********************************************************************
* Project: CoreCms
* ProjectName: 百分兵法管理系统
* Web: hhtp://chuanyin.com
* Author:
* Email:
* CreateTime: 202403/02
* Description: 暂无
***********************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using CoreCms.Net.Auth.HttpContextUser;
using CoreCms.Net.Configuration;
using CoreCms.Net.IServices;
using CoreCms.Net.Model.FromBody;
using CoreCms.Net.Model.ViewModels.UI;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace CoreCms.Net.Web.WebApi.Controllers
{
///
/// 微信小程序消息订阅接口
///
[Route("api/[controller]/[action]")]
[ApiController]
public class WeChatAppletsMessageController : ControllerBase
{
private readonly IHttpContextUser _user;
private readonly ICoreCmsUserWeChatMsgTemplateServices _userWeChatMsgTemplateServices;
private readonly ICoreCmsUserWeChatMsgSubscriptionSwitchServices _userWeChatMsgSubscriptionSwitchServices;
private readonly ICoreCmsUserWeChatMsgSubscriptionServices _userWeChatMsgSubscriptionServices;
///
/// 构造函数
///
public WeChatAppletsMessageController(IHttpContextUser user, ICoreCmsUserWeChatMsgTemplateServices userWeChatMsgTemplateServices, ICoreCmsUserWeChatMsgSubscriptionSwitchServices userWeChatMsgSubscriptionSwitchServices, ICoreCmsUserWeChatMsgSubscriptionServices userWeChatMsgSubscriptionServices)
{
_user = user;
_userWeChatMsgTemplateServices = userWeChatMsgTemplateServices;
_userWeChatMsgSubscriptionSwitchServices = userWeChatMsgSubscriptionSwitchServices;
_userWeChatMsgSubscriptionServices = userWeChatMsgSubscriptionServices;
}
#region 获取用户是否订阅
///
/// 获取用户是否订阅
///
///
[HttpPost]
[Authorize]
public async Task IsTip()
{
var jm = await _userWeChatMsgSubscriptionSwitchServices.IsTip(_user.ID);
return jm;
}
#endregion
#region 用户取消订阅
///
/// 用户取消订阅
///
///
[HttpPost]
[Authorize]
public async Task CloseTip()
{
var jm = await _userWeChatMsgSubscriptionSwitchServices.CloseTip(_user.ID);
return jm;
}
#endregion
#region 获取订阅模板
///
/// 获取订阅模板
///
///
[HttpPost]
[Authorize]
public async Task Tmpl()
{
var jm = await _userWeChatMsgSubscriptionServices.tmpl(_user.ID);
return jm;
}
#endregion
#region 设置订阅信息
///
/// 设置订阅信息
///
///
[HttpPost]
[Authorize]
public async Task SetTip([FromBody] SetWeChatAppletsMessageTip entity)
{
var jm = await _userWeChatMsgSubscriptionServices.SetTip(_user.ID, entity.templateId, entity.status);
return jm;
}
#endregion
}
}