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
{
///
/// SysRoleMenuController
///
[Route("api/[controller]/[action]")]
[ApiController]
[Authorize(Permissions.Name)]
public class SysRoleMenuController : BaseApiController
{
///
/// _sysRoleMenuService
///
private readonly ISysRoleMenuService _sysRoleMenuService;
///
/// 构造方法
///
///
public SysRoleMenuController(ISysRoleMenuService SysRoleMenuService)
{
_sysRoleMenuService = SysRoleMenuService;
}
///
/// 分页查询
///
/// 第几页
///
/// 每页大小
///
[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 = _sysRoleMenuService.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 = _sysRoleMenuService.QueryByIdAsync(id).Result
};
}
}
}