using JiepeiWMS.Common.Enums;
using JiepeiWMS.Common.Helper;
using JiepeiWMS.Common.HttpContextUser;
using JiepeiWMS.Extends;
using JiepeiWMS.IServices;
using JiepeiWMS.Model;
using JiepeiWMS.Model.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
namespace JiepeiWMS.Api.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]
[Authorize(Permissions.Name)]
public class SysOrgController : ControllerBase
{
///
/// 服务器接口,因为是模板生成,所以首字母是大写的,自己可以重构下
///
private readonly ISysOrgServices _BllSysOrg;
private readonly IUser _User;
public SysOrgController(ISysOrgServices BllSysOrg, IUser User)
{
_BllSysOrg = BllSysOrg;
_User = User;
}
[HttpGet]
public async Task>> GetList(int PageIndex = 1, string Key = "", int PageSize = 20)
{
if (string.IsNullOrEmpty(Key) || string.IsNullOrWhiteSpace(Key))
{
Key = "";
}
Expression> whereExpression = (pg, u) => pg.ShortName.Contains(Key);
return new MessageModel>()
{
msg = "获取成功",
success = true,
response = await _BllSysOrg.QueryPage(whereExpression, PageIndex, PageSize)
};
}
[HttpGet]
public async Task> Get(int id = 0)
{
var dictype = typeof(EnumSysOrgType)._GetValueDescriptionDicFromEnumType().Select(t => new { Key = t.Key.GetHashCode(), t.Value });
return new MessageModel