using Blog.Core.IServices;
using Blog.Core.Model;
using Blog.Core.Model.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Blog.Core.Controllers
{
///
/// WeChatCompanyController
///
[Route("api/[controller]/[action]")]
[ApiController]
[Authorize(Permissions.Name)]
public partial class WeChatCompanyController : Controller
{
readonly IWeChatCompanyServices _WeChatCompanyServices;
///
/// 构造函数
///
///
public WeChatCompanyController(IWeChatCompanyServices iWeChatCompanyServices)
{
_WeChatCompanyServices = iWeChatCompanyServices;
}
///
/// 获取
///
/// 分页条件
///
[HttpGet]
public async Task>> Get([FromQuery] PaginationModel pagination)
{
var data = await _WeChatCompanyServices.QueryPage(pagination);
return new MessageModel> { success = true, response = data};
}
///
/// 获取(id)
///
/// 主键ID
///
[HttpGet("{id}")]
public async Task> Get(string id)
{
var data = await _WeChatCompanyServices.QueryById(id);
return new MessageModel { success = true, response = data };
}
///
/// 添加
///
///
[HttpPost]
public async Task> Post([FromBody] WeChatCompany obj)
{
await _WeChatCompanyServices.Add(obj);
return new MessageModel { success = true};
}
///
/// 更新
///
///
[HttpPut]
public async Task> Put([FromBody] WeChatCompany obj)
{
await _WeChatCompanyServices.Update(obj);
return new MessageModel { success = true};
}
///
/// 删除
///
///
[HttpDelete]
public async Task> Delete(string id)
{
await _WeChatCompanyServices.DeleteById(id);
return new MessageModel { success = true};
}
///
/// 批量删除
///
///
[HttpDelete]
public async Task> BatchDelete(string ids)
{
var i = ids.Split(",");
await _WeChatCompanyServices.DeleteByIds(i);
return new MessageModel { success = true };
}
}
}