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

    }
}