using Admin.Core.Model;
using Admin.Core.Common.Resource;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;
using Admin.Core.Common;
using Admin.Core.IService.ISys;
using Admin.Core.Model.Sys;
namespace Admin.Core.Api
{
///
/// SysUserPostController
///
[Route("api/[controller]/[action]")]
[ApiController]
[Authorize(Permissions.Name)]
public class SysUserPostController : BaseApiController
{
///
/// _sysUserPostService
///
private readonly ISysUserPostService _sysUserPostService;
///
/// 构造方法
///
///
public SysUserPostController(ISysUserPostService SysUserPostService)
{
_sysUserPostService = SysUserPostService;
}
///
/// 分页查询
///
/// 第几页
///
/// 每页大小
///
[HttpGet]
public MessageModel> GetByPage(int page = 1, string key = "", int intPageSize = 50)
{
if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key))
{
key = "";
}
Expression> whereExpression = a => true;
var data = _sysUserPostService.QueryPageAsync(whereExpression, page, intPageSize, "UpdateTime").Result;
return SuccessPage(data);
}
///
/// 根据ID查询
///
/// 主键
///
[HttpGet]
public MessageModel GetByID(int id)
{
return new MessageModel()
{
msg = Resource_SysBase.OprateSuccess,
success = true,
data = _sysUserPostService.QueryByIdAsync(id).Result
};
}
}
}