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>
|
|
/// SysUserPostController
|
|
/// </summary>
|
|
[Route("api/[controller]/[action]")]
|
|
[ApiController]
|
|
[Authorize(Permissions.Name)]
|
|
public class SysUserPostController : BaseApiController
|
|
{
|
|
|
|
/// <summary>
|
|
/// _sysUserPostService
|
|
/// </summary>
|
|
private readonly ISysUserPostService _sysUserPostService;
|
|
|
|
/// <summary>
|
|
/// 构造方法
|
|
/// </summary>
|
|
/// <param name="SysUserPostService"></param>
|
|
public SysUserPostController(ISysUserPostService SysUserPostService)
|
|
{
|
|
_sysUserPostService = SysUserPostService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页查询
|
|
/// </summary>
|
|
/// <param name="page">第几页</param>
|
|
/// <param name="key"></param>
|
|
/// <param name="intPageSize">每页大小</param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public MessageModel<PageModel<SysUserPost>> GetByPage(int page = 1, string key = "", int intPageSize = 50)
|
|
{
|
|
if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key))
|
|
{
|
|
key = "";
|
|
}
|
|
|
|
Expression<Func<SysUserPost, bool>> whereExpression = a => true;
|
|
|
|
var data = _sysUserPostService.QueryPageAsync(whereExpression, page, intPageSize, "UpdateTime").Result;
|
|
return SuccessPage(data);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据ID查询
|
|
/// </summary>
|
|
/// <param name="id">主键</param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public MessageModel<SysUserPost> GetByID(int id)
|
|
{
|
|
return new MessageModel<SysUserPost>()
|
|
{
|
|
msg = Resource_SysBase.OprateSuccess,
|
|
success = true,
|
|
data = _sysUserPostService.QueryByIdAsync(id).Result
|
|
};
|
|
}
|
|
|
|
}
|
|
} |