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

    }
}