using System.Reflection;
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.Module.Core.Filters;
using DS.Module.Core.Helpers;
using DS.Module.Core.Modules;
using DS.Module.Core.Reflection;
using DS.Module.Jwt;
using DS.Module.Log;
using DS.Module.SqlSugar;
using DS.Module.Swagger;
using DS.Module.User;
using DS.WMS.Core.System.Dtos;
using FluentValidation;
using FluentValidation.AspNetCore;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace DS.WMS.WebApi;
///
/// 基础模块
///
[DSDependsOn(
typeof(DependencyAppModule),
typeof(NLogModule),
typeof(SqlSugarModule),
typeof(SwaggerModule),
typeof(JwtModule),
typeof(UserModule))]
public class DSAppWebModule : DSAppModule
{
private string policyName = string.Empty;
///
///
///
///
public override void ConfigureServices(ConfigureServicesContext context)
{
var service = context.Services;
service.AddControllersWithViews(options =>
{
// 全局添加自定义模型验证过滤器
// options.Filters.Add();
//全局异常过滤
options.Filters.Add();
options.SuppressAsyncSuffixInActionNames = false;
//x.Filters.Add();
})
.ConfigureApiBehaviorOptions(options =>
{
//使用自定义模型验证
options.InvalidModelStateResponseFactory = (context) =>
{
var errors = context.ModelState
.Where(e => e.Value.Errors.Count > 0)
.Select(e => e.Value.Errors.First().ErrorMessage)
.ToList();
var result = DataResult