namespace Tiobon.Core.Controllers
{
    /// <summary>
	/// WeChatSubController
	/// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize(Permissions.Name), ApiExplorerSettings(GroupName = Grouping.GroupName_WeChat)]
    public partial class WeChatSubController : Controller
    {
        readonly IWeChatSubServices _WeChatSubServices;
        /// <summary>
        /// 构造函数
        /// </summary> 
        /// <param name="iWeChatSubServices"></param> 
        public WeChatSubController(IWeChatSubServices iWeChatSubServices)
        {
            _WeChatSubServices = iWeChatSubServices;
        }
        /// <summary>
        /// 获取
        /// </summary>
        /// <param name="pagination">分页条件</param> 
        /// <returns></returns>
        [HttpGet]
        public async Task<ServiceResult<PageModel<WeChatSub>>> Get([FromQuery] PaginationModel pagination)
        {
            var data = await _WeChatSubServices.QueryPage(pagination);
            return new ServiceResult<PageModel<WeChatSub>> { Success = true, Data = data };
        }
        /// <summary>
        /// 获取(id)
        /// </summary>
        /// <param name="id">主键ID</param>
        /// <returns></returns>
        [HttpGet("{id}")]
        public async Task<ServiceResult<WeChatSub>> Get(string id)
        {
            var data = await _WeChatSubServices.QueryById(id);
            return new ServiceResult<WeChatSub> { Success = true, Data = data };
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<ServiceResult<string>> Post([FromBody] WeChatSub obj)
        {
            await _WeChatSubServices.Add(obj);
            return new ServiceResult<string> { Success = true };
        }
        /// <summary>
        /// 更新
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        public async Task<ServiceResult<string>> Put([FromBody] WeChatSub obj)
        {
            await _WeChatSubServices.Update(obj);
            return new ServiceResult<string> { Success = true };
        }
        /// <summary>
        /// 删除
        /// </summary> 
        /// <returns></returns> 
        [HttpDelete]
        public async Task<ServiceResult<string>> Delete(string id)
        {
            await _WeChatSubServices.DeleteById(id);
            return new ServiceResult<string> { Success = true };
        }
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <returns></returns>
        [HttpDelete]
        public async Task<ServiceResult<string>> BatchDelete(string ids)
        {
            var i = ids.Split(",");
            await _WeChatSubServices.DeleteByIds(i);
            return new ServiceResult<string> { Success = true };
        }

    }
}