using System;
using System.Reflection;
using System.Xml.Linq;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using SqlSugar;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Repositories;
using Yi.Framework.CodeGun.Application.Contracts.Dtos.Field;
using Yi.Framework.CodeGun.Application.Contracts.IServices;
using Yi.Framework.CodeGun.Domain.Entities;
using Yi.Framework.CodeGun.Domain.Shared.Enums;
using Yi.Framework.Ddd.Application;
using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Framework.CodeGun.Application.Services
{
///
/// 字段管理
///
public class FieldService : YiCrudAppService, IFieldService
{
private ISqlSugarRepository _repository;
public FieldService(ISqlSugarRepository repository) : base(repository)
{
_repository = repository;
}
public async override Task> GetListAsync([FromQuery] FieldGetListInput input)
{
RefAsync total = 0;
var entities = await _repository._DbQueryable.WhereIF(input.TableId is not null, x => x.TableId.Equals(input.TableId!))
.WhereIF(input.Name is not null, x => x.Name!.Contains(input.Name!))
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
return new PagedResultDto
{
TotalCount = total,
Items = await MapToGetListOutputDtosAsync(entities)
};
}
///
/// 获取类型枚举
///
///
[Route("type")]
public object GetFieldTypeEnum()
{
return typeof(FieldTypeEnum).GetFields(BindingFlags.Static | BindingFlags.Public).Select(x => new { lable = x.Name, value = (int)Enum.Parse(typeof(FieldTypeEnum), x.Name) }).ToList();
}
}
}