You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.2 KiB
C#
76 lines
2.2 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// SysUserRoleController
|
|
/// </summary>
|
|
[Route("api/[controller]/[action]")]
|
|
[ApiController]
|
|
[Authorize(Permissions.Name)]
|
|
public class SysUserRoleController : BaseApiController
|
|
{
|
|
|
|
/// <summary>
|
|
/// _sysUserRoleService
|
|
/// </summary>
|
|
private readonly ISysUserRoleService _sysUserRoleService;
|
|
|
|
/// <summary>
|
|
/// 构造方法
|
|
/// </summary>
|
|
/// <param name="SysUserRoleService"></param>
|
|
public SysUserRoleController(ISysUserRoleService SysUserRoleService)
|
|
{
|
|
_sysUserRoleService = SysUserRoleService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页查询
|
|
/// </summary>
|
|
/// <param name="page">第几页</param>
|
|
/// <param name="key"></param>
|
|
/// <param name="intPageSize">每页大小</param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public MessageModel<PageModel<SysUserRole>> GetByPage(int page = 1, string key = "", int intPageSize = 50)
|
|
{
|
|
if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key))
|
|
{
|
|
key = "";
|
|
}
|
|
|
|
Expression<Func<SysUserRole, bool>> whereExpression = a => true;
|
|
|
|
var data = _sysUserRoleService.QueryPageAsync(whereExpression, page, intPageSize, "UpdateTime").Result;
|
|
return SuccessPage(data);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据ID查询
|
|
/// </summary>
|
|
/// <param name="id">主键</param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public MessageModel<SysUserRole> GetByID(int id)
|
|
{
|
|
return new MessageModel<SysUserRole>()
|
|
{
|
|
msg = Resource_SysBase.OprateSuccess,
|
|
success = true,
|
|
data = _sysUserRoleService.QueryByIdAsync(id).Result
|
|
};
|
|
}
|
|
|
|
}
|
|
} |