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

    }
}