清理工程文件

This commit is contained in:
李鹏军 2024-03-01 10:27:55 +08:00
parent 945463dc91
commit 7f14abe027
40 changed files with 102 additions and 1017 deletions

View File

@ -10,10 +10,10 @@ try
.AddConfigurationContainer()
.AddOptionsFromConfiguration()
.UseSerilogDefault()
.Host.AddAppSettingsSecretsJson()
.Host.AddAppSettingsSecretsJson()
.UseAutofac();
await builder.AddApplicationAsync<SJZYTrackApiModule>();
await builder.AddApplicationAsync<SjzyTrackApiModule>();
var app = builder.Build();
await app.InitializeApplicationAsync();

View File

@ -1,34 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..</DockerfileContext>
</PropertyGroup>
<Import Project="../../common.props"/>
<ItemGroup>
<Compile Remove="logs\**" />
<Content Remove="logs\**" />
<EmbeddedResource Remove="logs\**" />
<None Remove="logs\**" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..</DockerfileContext>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentValidation.AspNetCore" Version="11.2.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.2" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Volo.Abp.Autofac" Version="7.0.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SJZY.Track.Application\SJZY.Track.Application.csproj" />
<ProjectReference Include="..\SJZY.Track.Infrastructure\SJZY.Track.Infrastructure.csproj"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="FluentValidation.AspNetCore" Version="11.2.2"/>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.2"/>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0"/>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0"/>
<PackageReference Include="Volo.Abp.Autofac" Version="7.0.2"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SJZY.Track.Application\SJZY.Track.Application.csproj"/>
<ProjectReference Include="..\SJZY.Track.Infrastructure\SJZY.Track.Infrastructure.csproj"/>
</ItemGroup>
</Project>

View File

@ -27,10 +27,10 @@ namespace SJZY.Track.Api
typeof(SjzyAbpCodeModule),
typeof(AbpAspNetCoreMvcModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(ApplicationModule),
typeof(SJZYTrackInfrastructureModule)
typeof(SjzyTrackApplicationModule),
typeof(SjzyTrackInfrastructureModule)
)]
public class SJZYTrackApiModule : AbpModule
public class SjzyTrackApiModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{

View File

@ -1,85 +0,0 @@
namespace SJZY.Track.Application.Contract.Dtos.Demo
{
/// <summary>
/// automapper 复杂转换样例
/// </summary>
public class ComplexAutomapperDemoInput
{
/// <summary>
/// 编号
/// </summary>
public int Id { get; set; }
/// <summary>
/// 操作类型
/// </summary>
public OptionType OptionType { get; set; }
/// <summary>
/// 描述
/// </summary>
public string Description { get; set; }
/// <summary>
/// 性别
/// </summary>
public Gender Gender { get; set; }
/// <summary>
/// 用户信息
/// </summary>
public UserInfoInput UserInfo { get; set; }
/// <summary>
/// 用户角色
/// </summary>
public List<UserRoleInput> UserRoleInputList { get; set; }
/// <summary>
/// 拓展演示,目前大家共同约定,暂时不使用充血模型
/// </summary>
/// <returns></returns>
public string GetAddress()
{
return "辽宁省沈阳市...";
}
}
public class ComplexAutomapperDemoOutput
{
/// <summary>
/// 编号
/// </summary>
public int Id { get; set; }
/// <summary>
/// 性别
/// </summary>
public string Gender { get; set; }
/// <summary>
/// 描述
/// </summary>
public string Description { get; set; }
/// <summary>
/// 年龄
/// </summary>
public int Age { get; set; }
/// <summary>
/// qq号码
/// </summary>
public string QQ { get; set; }
/// <summary>
/// 地址
/// </summary>
public string Address { get; set; }
/// <summary>
/// 角色编号
/// </summary>
public int[] RoleIds { get; set; }
}
}

View File

@ -1,48 +0,0 @@
namespace SJZY.Track.Application.Contract.Dtos.Demo
{
public class DemoDetailSaveInput
{
/// <summary>
///
/// </summary>
public int Id { get; set; }
/// <summary>
/// 姓名
/// </summary>
public string Name { get; set; }
/// <summary>
/// 年龄
/// </summary>
public int Age { get; set; }
/// <summary>
/// 描述
/// </summary>
public string Description { get; set; }
/// <summary>
/// 详情合集
/// </summary>
public List<DemoDetailInput> DemoDetailList { get; set; }
}
public class DemoDetailInput
{
/// <summary>
/// Id
/// </summary>
public int Id { get; set; }
/// <summary>
/// t_demo.id
/// </summary>
public int DemoId { get; set; }
/// <summary>
/// 一些说明..
/// </summary>
public string OtherInfo { get; set; }
}
}

View File

@ -1,42 +0,0 @@
namespace SJZY.Track.Application.Contract.Dtos.Demo
{
public class DemoInput
{
/// <summary>
/// 操作类型
/// </summary>
public OptionType Option { get; set; }
/// <summary>
///
/// </summary>
public int Id { get; set; }
/// <summary>
/// 姓名
/// </summary>
public string Name { get; set; }
/// <summary>
/// 年龄
/// </summary>
public int Age { get; set; }
/// <summary>
/// 描述
/// </summary>
public string Description { get; set; }
//以下两个属性用来说明类型转换
/// <summary>
/// 创建人id
/// </summary>
public string CreateUserId { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public string CreateTime { get; set; }
}
}

View File

@ -1,10 +0,0 @@
namespace SJZY.Track.Application.Contract.Dtos.Demo;
public class ExcelImportOuput
{
// [MiniExcelLibs.Attributes.ExcelColumnName("姓名")]
public string Name { get; set; }
// [MiniExcelLibs.Attributes.ExcelColumnName("年龄")]
public int Age { get; set; }
}

View File

@ -1,9 +0,0 @@
namespace SJZY.Track.Application.Contract.Dtos.Demo;
public class GetDemoListByPageInput : PageInfoInput
{
/// <summary>
/// 姓名
/// </summary>
public string Name { get; set; }
}

View File

@ -1,27 +0,0 @@
namespace SJZY.Track.Application.Contract.Dtos.Demo
{
public class GetDemoListByPageOutput
{
/// <summary>
///
/// </summary>
public int Id { get; set; }
/// <summary>
/// 姓名
/// </summary>
public string Name { get; set; }
/// <summary>
/// 年龄
/// </summary>
public int Age { get; set; }
/// <summary>
/// 描述
/// </summary>
public string Description { get; set; }
public DateTime CreateTime { get; set; }
}
}

View File

@ -1,9 +0,0 @@
namespace SJZY.Track.Application.Contract.Dtos.Demo
{
public class MyCustomerResultOutput
{
public string Code { get; set; }
public string Message { get; set; }
}
}

View File

@ -1,15 +0,0 @@
namespace SJZY.Track.Application.Contract.Dtos.Demo
{
public class OssUploadOutput
{
/// <summary>
/// 文件key
/// </summary>
public string Key { get; set; }
/// <summary>
/// 文件路径
/// </summary>
public string Url { get; set; }
}
}

View File

@ -1,10 +0,0 @@
namespace SJZY.Track.Application.Contract.Dtos
{
public class RemoteDemoInput
{
/// <summary>
/// 当前时间
/// </summary>
public DateTime CurrentTime { get; set; }
}
}

View File

@ -1,7 +0,0 @@
namespace SJZY.Track.Application.Contract.Dtos
{
public class RemoteDemoOutput
{
public string Context { get; set; }
}
}

View File

@ -1,39 +0,0 @@
using System.ComponentModel;
using System.Text.Json.Serialization;
namespace SJZY.Track.Application.Contract.Dtos.Demo
{
public class SwaggerDemoInput
{
/// <summary>
/// 年龄
/// </summary>
/// <example>18</example> 这里可以写一些初始值
public int Age { get; set; }
/// <summary>
/// 姓名
/// </summary>
public string Name { get; set; }
/// <summary>
/// 性别(枚举的展示样例)
/// </summary>
public Gender Gender { get; set; }
/// <summary>
/// 隐藏属性
/// </summary>
[JsonIgnore]
public int MyProperty { get; set; }
}
public enum Gender
{
[Description("纯爷们")] 男 = 2,
[Description("大姑娘")] 女 = 5,
[Description("你憋问")] 未知 = 8
}
}

View File

@ -1,97 +0,0 @@
namespace SJZY.Track.Application.Contract.Dtos.Demo
{
public class ValidateExecuteInput
{
/// <summary>
/// 操作类型
/// </summary>
public OptionType Option { get; set; }
/// <summary>
/// 主键编号
/// </summary>
public int Id { get; set; }
/// <summary>
/// 雪花ID
/// </summary>
public long SnowId { get; set; }
/// <summary>
/// 登录账号
/// </summary>
public string LoginName { get; set; }
/// <summary>
/// 登录密码
/// </summary>
public string? PassWord { get; set; }
/// <summary>
/// 登录密码确认
/// </summary>
public string PassWordAgain { get; set; }
/// <summary>
/// 最大金额额度
/// </summary>
public decimal TotalQuota { get; set; }
/// <summary>
/// 最大数量
/// </summary>
public int MaxCount { get; set; }
/// <summary>
/// 最小数量
/// </summary>
public int MiniCount { get; set; }
/// <summary>
/// 用户信息
/// </summary>
public UserInfoInput UserInfoInput { get; set; }
/// <summary>
/// 用户角色
/// </summary>
public List<UserRoleInput> UserRoleInputList { get; set; }
}
public class UserInfoInput
{
/// <summary>
/// 生日
/// </summary>
public DateTime BirthDay { get; set; }
/// <summary>
/// qq号码
/// </summary>
public string QQ { get; set; }
/// <summary>
/// 电子邮箱
/// </summary>
public string Email { get; set; }
/// <summary>
/// 用户姓名
/// </summary>
public string UserName { get; set; }
}
public class UserRoleInput
{
/// <summary>
/// 角色编号
/// </summary>
public int Id { get; set; }
/// <summary>
/// 角色名称
/// </summary>
public string Name { get; set; }
}
}

View File

@ -1,6 +0,0 @@
namespace SJZY.Track.Application.Contract.Dtos.Demo
{
public class ValidateExecuteOutput
{
}
}

View File

@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../../common.props"/>
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.0.2</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SJZY.Expand.ABP.Common" Version="7.0.11" />
<PackageReference Include="Volo.Abp.Core" Version="7.0.2" />
<PackageReference Include="SJZY.Expand.ABP.Common" Version="7.0.11"/>
<PackageReference Include="Volo.Abp.Core" Version="7.0.2"/>
</ItemGroup>
</Project>

View File

@ -1,13 +0,0 @@
using SJZY.Track.Application.Contract.Dtos;
using Volo.Abp;
using Volo.Abp.DependencyInjection;
namespace SJZY.Track.Application.Contract.Services;
/// <summary>
/// 客户端连接测试接口
/// </summary>
public interface IRemoteDemoService : IRemoteService, IScopedDependency
{
Task<UnifyResultDto<RemoteDemoOutput>> ConnectionTest(RemoteDemoInput input);
}

View File

@ -0,0 +1,10 @@
using Volo.Abp.Modularity;
namespace SJZY.Track.Application.Contract;
public class SjzyTrackApplicationContractModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
}
}

View File

@ -1,11 +0,0 @@
using Volo.Abp.Modularity;
namespace SJZY.Track.Application.Contract
{
public class TrackHttpApiModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
}
}
}

View File

@ -1,33 +0,0 @@
using AutoMapper;
using SJZY.Track.Application.Contract.Dtos.Demo;
using SJZY.Track.Domain.Aggregates.DemoAggregate;
using SJZY.Track.Domain.Dtos.Demo;
namespace SJZY.Track.Application.AutoMapper;
internal class AutoMapperProfile : Profile
{
public AutoMapperProfile()
{
CreateMap<UnifyPageResultDto<DemoEntity>, UnifyPageResultDto<GetDemoListByPageOutput>>(MemberList.None);
CreateMap<GetDemoListByPageInput, DemoValueObject>(MemberList.None).ReverseMap();
CreateMap<UnifyPageResultDto<GetDemoListByPageInput>, UnifyPageResultDto<DemoValueObject>>(MemberList.None)
.ReverseMap();
/*
代码说明:
MemberList.None的意思是,忽略源对象和目标对象的属性匹配检查,其他可选值:MemberList.Source(检查是否映射了所有源成员)、MemberList.Destination(检查是否映射了所有目标成员)
.ReverseMap()的意思是配置双向调用关系,既一行代码既支持从 GetDemoListByPageInput -> DemoValueObject 的映射,同时也支持从 DemoValueObject -> GetDemoListByPageInput 的映射
如果对一对模型多次配置规则,会以最后一次为准,配置了这样规则后,最终执行结果是 Name + 444
CreateMap<DemoInput, DemoEntity>().ForMember(dest => dest.Description, opt => opt.MapFrom(m => m.Name + "22"));
CreateMap<DemoInput, DemoEntity>().ForMember(dest => dest.Description, opt => opt.MapFrom(m => m.Name + "444"));
*/
CreateMap<DemoEntity, DemoInput>(MemberList.None).ReverseMap();
CreateMap<DemoEntity, GetDemoListByPageOutput>(MemberList.None);
CreateMap<DemoEntity, DemoDetailSaveInput>(MemberList.None).ReverseMap();
}
}

View File

@ -1,44 +0,0 @@
using AutoMapper;
using SJZY.Expand.ABP.Core.PublicMethords;
using SJZY.Track.Application.Contract.Dtos.Demo;
namespace SJZY.Track.Application.AutoMapper
{
/// <summary>
/// 稍复杂的配置类
/// </summary>
internal class DemoAutoMapperProfile : Profile
{
public DemoAutoMapperProfile()
{
CreateMap<ComplexAutomapperDemoInput, ComplexAutomapperDemoOutput>(MemberList.None)
//层级不一致的场景
.ForMember(dest => dest.QQ, opt => opt.MapFrom(source => source.UserInfo.QQ))
//数据类型不一致的场景,这里如果不指定映射规则会直接取枚举的key值
.ForMember(dest => dest.Gender, opt => opt.MapFrom(source => source.Gender.GetDescription()))
//一些简单计算的场景,酌情使用...
.ForMember(dest => dest.Age, opt => opt.MapFrom(source => GetAgeByBirthdate(source.UserInfo.BirthDay)))
//结构不一致的场景
.ForMember(dest => dest.RoleIds,
opt => opt.MapFrom(source => source.UserRoleInputList.Select(m => m.Id).ToArray()))
//条件映射(这里只是举例,日常开发时sqlsugar在新增时会避开自增主键)
.ForMember(dest => dest.Id,
opt =>
{
opt.Condition(src => src.OptionType == OptionType.删除 || src.OptionType == OptionType.修改);
});
}
public int GetAgeByBirthdate(DateTime birthdate)
{
DateTime now = DateTime.Now;
int age = now.Year - birthdate.Year;
if (now.Month < birthdate.Month || (now.Month == birthdate.Month && now.Day < birthdate.Day))
{
age--;
}
return age < 0 ? 0 : age;
}
}
}

View File

@ -5,3 +5,4 @@ global using SJZY.Expand.ABP.Core.Common.Dto;
global using Volo.Abp;
global using Volo.Abp.Application.Services;
global using Volo.Abp.Validation;
global using SJZY.Track.Domain;

View File

@ -1,3 +0,0 @@
// Global using directives
global using SJZY.Track.Domain;

View File

@ -1,32 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../../common.props" />
<Import Project="../../common.props"/>
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Services\TrackMap\**" />
<Compile Remove="Validations\Docuai\**" />
<EmbeddedResource Remove="Services\TrackMap\**" />
<EmbeddedResource Remove="Validations\Docuai\**" />
<None Remove="Services\TrackMap\**" />
<None Remove="Validations\Docuai\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Http.Client" Version="7.0.2"/>
<PackageReference Include="Volo.Abp.FluentValidation" Version="7.0.2"/>
<PackageReference Include="SJZY.UserCenter.HttpApi" Version="3.0.3-alpha8"/>
<PackageReference Include="SJZY.Expand.CAP" Version="7.8.0"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="SJZY.Expand.AliyunOSS" Version="7.0.10"/>
<PackageReference Include="SJZY.Expand.Excel" Version="7.0.5"/>
<PackageReference Include="Volo.Abp.Http.Client" Version="7.0.2"/>
<PackageReference Include="Volo.Abp.FluentValidation" Version="7.0.2"/>
<PackageReference Include="SJZY.UserCenter.HttpApi" Version="3.0.3-alpha8"/>
<PackageReference Include="SJZY.Expand.CAP" Version="7.8.0"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SJZY.Track.Domain\SJZY.Track.Domain.csproj" />
<ProjectReference Include="..\SJZY.Track.Application.Contract\SJZY.Track.Application.Contract.csproj"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SJZY.Track.Domain\SJZY.Track.Domain.csproj"/>
<ProjectReference Include="..\SJZY.Track.Application.Contract\SJZY.Track.Application.Contract.csproj"/>
</ItemGroup>
</Project>

View File

@ -1,251 +0,0 @@
using SJZY.Expand.ABP.Core.Common;
using SJZY.Track.Application.Contract.Dtos.Demo;
using SJZY.Track.Domain.Aggregates.DemoAggregate;
using SJZY.Track.Domain.Dtos.Demo;
namespace SJZY.Track.Application.Services.Demo;
/// <summary>
/// 接口请求完整样例
/// </summary>
[ApiExplorerSettings(GroupName = "Demo")]
public class InterFaceDemoService : ApplicationService
{
#region 构造函数
private readonly IDemoRepository _demoRepository;
public InterFaceDemoService(IDemoRepository demoRepository)
{
_demoRepository = demoRepository;
}
#endregion
#region 增删改
/// <summary>
/// 增删改
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("InterFace/Edit")]
public async Task<LongIdBaseDto> Edit(DemoInput input)
{
var res = new LongIdBaseDto();
if (input.Option == OptionType.新增)
{
var entity = ObjectMapper.Map<DemoInput, DemoEntity>(input);
res.Id = await _demoRepository.InsertReturnIdentityAsync(entity);
}
else if (input.Option == OptionType.修改 || input.Option == OptionType.删除)
{
var demoInfo = await _demoRepository.GetById1(input.Id);
if (demoInfo == null)
{
//校验数据是否存在...
throw new BusinessException(message: "未找到指定编号下的数据");
}
res.Id = demoInfo.Id;
if (input.Option == OptionType.删除)
{
//await _demoRepository.DeleteAsync(demoInfo); //真删除
//软删除
demoInfo.IsDeleted = true;
await _demoRepository.UpdateAsync(demoInfo);
}
else
{
var entity = ObjectMapper.Map(input, demoInfo);
await _demoRepository.UpdateAsync(entity);
}
}
return res;
}
#endregion
#region 局部更新最佳实践
/// <summary>
/// 局部更新最佳实践
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="BusinessException"></exception>
[HttpPost("InterFace/UpdatePartColumns")]
public async Task<IdBaseDto> UpdatePartColumns(DemoInput input)
{
var demoInfo = await _demoRepository.GetById1(input.Id);
if (demoInfo == null)
{
//校验数据是否存在...
throw new BusinessException(message: "未找到指定编号下的数据");
}
//更新同时忽略某几项参数
await _demoRepository.UpdatePartColumns(demoInfo);
return new IdBaseDto() { Id = input.Id };
}
#endregion
#region 分页查询接口
/// <summary>
/// 分页查询
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("InterFace/GetListByPage")]
public async Task<UnifyPageResultDto<GetDemoListByPageOutput>> GetListByPage(GetDemoListByPageInput input)
{
//分页时返回值统一用 PageResultDto<> 类型
var list = await _demoRepository.GetListByPage(input.PageSize, input.PageIndex, input.Name);
var res = ObjectMapper.Map<UnifyPageResultDto<DemoEntity>, UnifyPageResultDto<GetDemoListByPageOutput>>(list);
return res;
}
#endregion
#region 入参转换
/// <summary>
/// 入参转换
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("InterFace/InputToValueObject")]
public async Task<List<GetDemoListByPageOutput>> InputToValueObject(GetDemoListByPageInput input)
{
var obj = ObjectMapper.Map<GetDemoListByPageInput, DemoValueObject>(input);
var list = await _demoRepository.InputToValueObject(obj);
var res = ObjectMapper.Map<List<DemoEntity>, List<GetDemoListByPageOutput>>(list);
return res;
}
#endregion
#region 原生sql
/// <summary>
/// 原生sql
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
[HttpPost("InterFace/OriginalSql")]
public async Task<UnifyPageResultDto<DemoValueObject>> OriginalSql(DemoValueObject obj)
{
var list = await _demoRepository.OriginalSql(obj);
return list;
}
#endregion
#region 自定义返回结果格式
/// <summary>
/// 自定义返回结果格式
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("Demo/CustomerResult")]
[CustomerResult]
public async Task<MyCustomerResultOutput> GetListAsync()
{
/*
说明:
理论上我们有全公司级别的返回值约定,不管是前端调后端,还是后端微服务间的调用,都应完全遵循该规范。
但不排除有些特殊情况下,必须要返回自定义格式的场景。
*/
var res = new MyCustomerResultOutput();
res.Code = "200";
res.Message = "这是一个自定义返回结果";
return res;
}
#endregion
#region 约定类型下返回null
/// <summary>
/// 约定类型下返回null
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("Demo/ReturnNull")]
public async Task<MyCustomerResultOutput> ReturnNull()
{
MyCustomerResultOutput res = null;
return res;
}
#endregion
#region
/// <summary>
/// 没有返回值
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("Demo/WithoutReturnObject")]
public async Task<UnifyResultDto> WithoutReturnObject()
{
return null;
}
#endregion
#region 主从关系实体存储
/// <summary>
/// 主从关系实体存储
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
[HttpPost("InterFace/EntityRelationSave")]
public async Task<UnifyResultDto> EntityRelationSave(DemoDetailSaveInput input)
{
var obj = ObjectMapper.Map<DemoDetailSaveInput, DemoEntity>(input);
var res = await _demoRepository.EntityRelationSave(obj);
return new UnifyResultDto(res);
}
#endregion
#region 数据缓存
/// <summary>
/// 数据缓存
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("InterFace/GetDataCache")]
public async Task<DemoEntity> GetDataCache(IdBaseDto input)
{
var res = await _demoRepository.GetDataCache(input.Id);
return res;
}
#endregion
//[HttpPost("InterFace/AAAA")]
//public async Task<UnifyResultDto> AAAA()
//{
// var result = await _httpClientProxy.Service.GetSystemTokenAsync("Track");
// return result;
//}
}

View File

@ -1,4 +1,5 @@
using SJZY.Expand.ABP.Core.Localization;
using SJZY.Track.Application.Contract;
using SJZY.Track.Application.Localization;
using SJZY.UserCenter.Contracts;
using SJZY.UserCenter.SharedModel;
@ -19,25 +20,26 @@ namespace SJZY.Track.Application
typeof(AbpLocalizationModule),
typeof(AbpVirtualFileSystemModule),
typeof(AbpHttpClientModule),
typeof(SJZYTrackDomainModule),
typeof(SjzyUserCenterHttpApiModule)
typeof(SjzyUserCenterHttpApiModule),
typeof(SjzyTrackDomainModule),
typeof(SjzyTrackApplicationContractModule)
)]
public class ApplicationModule : AbpModule
public class SjzyTrackApplicationModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
Configure<AbpAutoMapperOptions>(options => { options.AddMaps<ApplicationModule>(true); });
Configure<AbpAutoMapperOptions>(options => { options.AddMaps<SjzyTrackApplicationModule>(true); });
Configure<AbpAspNetCoreMvcOptions>(options =>
{
options.ConventionalControllers.Create(typeof(ApplicationModule).Assembly); //创建动态api
options.ConventionalControllers.Create(typeof(SjzyTrackApplicationModule).Assembly); //创建动态api
});
//添加虚拟文件系统
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<ApplicationModule>("SJZY.Track.Application");
options.FileSets.AddEmbedded<SjzyTrackApplicationModule>("SJZY.Track.Application");
});
//添加多语言

View File

@ -1,67 +0,0 @@
using FluentValidation;
using SJZY.Track.Application.Contract.Dtos.Demo;
namespace SJZY.Track.Application.Validations.Demo
{
public class SimpleValidateInputValidation : AbstractValidator<ValidateExecuteInput>, IValidationEnabled
{
public SimpleValidateInputValidation()
{
/*
非空校验
NotNull 和 NotEmpty 的区别?
NotNull:请求中没找到指定参数
NotEmpty:请求中没找到指定参数 或 参数值为初始值(0/"")
关于字符串的最佳实践:
参数定义成可空字符串 string?,校验规则只用isempty
*/
RuleFor(x => x.PassWord).NotNull().WithMessage("操作密码为必填参数!").NotEmpty().WithMessage("操作密码不能为空!");
//雪花id
RuleFor(x => x.SnowId).NotNull().WithMessage("雪花ID为必填参数!").NotEmpty().WithMessage("雪花ID不能为空!");
//枚举校验
RuleFor(x => x.Option).IsInEnum().WithMessage("操作类型不在可选范围!");
//字符串长度校验,长度不分中文、字符、数值
RuleFor(x => x.LoginName).Length(6, 10).WithMessage("登录账号必须在6-10位之间!");
RuleFor(x => x.LoginName).MaximumLength(10).WithMessage("登录账号不能超过10个字符!");
RuleFor(x => x.LoginName).MinimumLength(6).WithMessage("登录账号不能小于6个字符!");
//正则表达式
RuleFor(x => x.PassWord)
.Matches(
"^(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[!@#$\\%\\^\\&\\*\\(\\)])[0-9a-zA-Z!@#$\\%\\^\\&\\*\\(\\)]{6,10}")
.WithMessage("密码必须同时包含数字、英文字母、特殊字符,且长度必须在6-10位之间");
//自定义校验规则,注意这里的校验仅限于模型参数级的校验,更复杂的业务校验应在业务层完成
RuleFor(x => x.PassWordAgain).Must((data, context) => { return data.PassWord == data.PassWordAgain; })
.WithMessage("两次输入密码不一致!");
//数字类型校验
RuleFor(x => x.MiniCount).LessThan(100).WithMessage("最小数量必须小于100");
RuleFor(x => x.MiniCount).LessThanOrEqualTo(100).WithMessage("最小数量必须小于或等于100");
RuleFor(x => x.MaxCount).GreaterThan(100).WithMessage("最大数量必须大于100");
RuleFor(x => x.MaxCount).GreaterThanOrEqualTo(100).WithMessage("最大数量必须大于或等于100");
//小数类型校验,10.56
RuleFor(x => x.TotalQuota).ScalePrecision(2, 4, true).WithMessage("最大额度金额【整数位+小数位】不能超过4位,且小数位不能超过2位");
//条件分支
When(x => x.Option == OptionType.修改 || x.Option == OptionType.删除,
() =>
{
RuleFor(x => x.Id).NotNull().WithMessage("修改或删除时Id为必填参数!").GreaterThan(0)
.WithMessage("修改或删除时Id必须大于0!");
});
//单个实体校验
RuleFor(x => x.UserInfoInput).NotNull().WithMessage("用户信息为必填参数!")
.SetValidator(new UserInfoInputValidation());
//集合校验
RuleForEach(x => x.UserRoleInputList).SetValidator(new UserRoleInputValidation());
}
}
}

View File

@ -1,13 +0,0 @@
using FluentValidation;
using SJZY.Track.Application.Contract.Dtos.Demo;
namespace SJZY.Track.Application.Validations.Demo
{
public class UserInfoInputValidation : AbstractValidator<UserInfoInput>, IValidationEnabled
{
public UserInfoInputValidation()
{
RuleFor(x => x.QQ).NotNull().WithMessage("QQ号码不能为空");
}
}
}

View File

@ -1,13 +0,0 @@
using FluentValidation;
using SJZY.Track.Application.Contract.Dtos.Demo;
namespace SJZY.Track.Application.Validations.Demo
{
public class UserRoleInputValidation : AbstractValidator<UserRoleInput>, IValidationEnabled
{
public UserRoleInputValidation()
{
RuleFor(m => m.Id).GreaterThan(0).WithMessage("角色ID必须大于0!");
}
}
}

View File

@ -10,7 +10,7 @@ public interface IBasicRepository<T> : IBasicQuery<T> where T : IAggregateRoot
/// <param name="entity"></param>
/// <param name="ignoreColumns">要忽略更新的列</param>
/// <returns></returns>
Task<bool> UpdateAsync(T entity, Expression<Func<T, object>> ignoreColumns);
Task<bool> UpdateAsync(T entity, Expression<Func<T, object>>? ignoreColumns);
/// <summary>
/// update
@ -18,7 +18,7 @@ public interface IBasicRepository<T> : IBasicQuery<T> where T : IAggregateRoot
/// <param name="entity"></param>
/// <param name="updateColumns">要更新的列</param>
/// <returns></returns>
Task<bool> UpdateColumnAsync(T entity, Expression<Func<T, object>> updateColumns);
Task<bool> UpdateColumnAsync(T entity, Expression<Func<T, object>>? updateColumns);
/// <summary>
/// update

View File

@ -11,8 +11,4 @@
<PackageReference Include="SJZY.Expand.ElasticSearch" Version="7.0.17" />
</ItemGroup>
<ItemGroup>
<Folder Include="Aggregates\" />
</ItemGroup>
</Project>

View File

@ -2,6 +2,6 @@
namespace SJZY.Track.Domain;
public class SJZYTrackDomainModule : AbpModule
public class SjzyTrackDomainModule : AbpModule
{
}

View File

@ -12,14 +12,14 @@ namespace SJZY.Track.Infrastructure.Repositories;
/// <typeparam name="T"></typeparam>
public class BasicRepository<T> : BasicQuery<T>, IBasicRepository<T> where T : class, IAggregateRoot, new()
{
public async Task<bool> UpdateAsync(T entity, Expression<Func<T, object>> ignoreColumns)
public async Task<bool> UpdateAsync(T entity, Expression<Func<T, object>>? ignoreColumns)
{
return await Context.Updateable(entity)
.IgnoreColumnsIF(ignoreColumns != null, ignoreColumns)
.ExecuteCommandHasChangeAsync();
}
public async Task<bool> UpdateColumnAsync(T entity, Expression<Func<T, object>> updateColumns)
public async Task<bool> UpdateColumnAsync(T entity, Expression<Func<T, object>>? updateColumns)
{
return await Context.Updateable(entity)
.UpdateColumnsIF(updateColumns != null, updateColumns)
@ -40,15 +40,13 @@ public class BasicRepository<T> : BasicQuery<T>, IBasicRepository<T> where T : c
.ExecuteCommandHasChangeAsync();
}
// tips: required where
public async Task<bool> SoftDeleteAsync(Expression<Func<T, bool>> where)
{
if (!typeof(T).IsAssignableTo<ISoftDeleteBasicEntity>())
throw new BusinessException(
message: $"实体没有实现{nameof(ISoftDeleteBasicEntity)}不能调用{nameof(SoftDeleteAsync)}");
// tips: required where
if (where == default) return false;
return await Context.Updateable<T>()
.Where(where)
.SetColumns(nameof(ISoftDeleteBasicEntity.IsDeleted), 1)

View File

@ -6,10 +6,6 @@ namespace SJZY.Track.Infrastructure.Repositories;
public class TrackStatusRepository : BasicRepository<TrackStatusEntity>, ITrackStatusRepository, IScopedDependency
{
public TrackStatusRepository()
{
}
/// <summary>
/// 获取轨迹状态明细
/// </summary>
@ -41,8 +37,7 @@ public class TrackStatusRepository : BasicRepository<TrackStatusEntity>, ITrackS
/// <returns></returns>
public async Task<UnifyPageResultDto<GetTrackStatusListVO>> GetPageTrackStatus(GetPageTrackStatusVO input)
{
UnifyPageResultDto<GetTrackStatusListVO> pagedList = new UnifyPageResultDto<GetTrackStatusListVO>();
pagedList = await Context.Queryable<TrackStatusEntity>()
UnifyPageResultDto<GetTrackStatusListVO> pagedList = await Context.Queryable<TrackStatusEntity>()
.LeftJoin<VSystemEntity>((a, b) => a.SubSystemId == b.Id)
.LeftJoin<VUserEntity>((a, b, c) => a.CreateUserId == c.Id)
.LeftJoin<VUserEntity>((a, b, c, d) => a.UpdateUserId == d.Id)
@ -57,9 +52,10 @@ public class TrackStatusRepository : BasicRepository<TrackStatusEntity>, ITrackS
EntrackStatus = a.EnStatus,
TrackStatus = a.Status,
NodeId = a.Node,
Node = SqlFunc.IF(a.Node == 1).Return("揽收").ElseIF(a.Node == 2).Return("干线").ElseIF(a.Node == 3).Return("清关")
.ElseIF(a.Node == 4).Return("中转").ElseIF(a.Node == 5).Return("派送")
.End(""),
Node = SqlFunc.IF(a.Node == 1).Return("揽收").ElseIF(a.Node == 2).Return("干线").ElseIF(a.Node == 3)
.Return("清关")
.ElseIF(a.Node == 4).Return("中转").ElseIF(a.Node == 5).Return("派送")
.End(""),
CreateTime = a.CreateTime,
CreateUser = c.Name,
UpdateTime = a.UpdateTime,

View File

@ -1,37 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../../common.props" />
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<LangVersion>preview</LangVersion>
</PropertyGroup>
<Import Project="../../common.props"/>
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<LangVersion>preview</LangVersion>
</PropertyGroup>
<ItemGroup>
<Compile Remove="DataCenter\**" />
<EmbeddedResource Remove="DataCenter\**" />
<None Remove="DataCenter\**" />
<Compile Remove="TrackTemplate\ValueObjects\**" />
<EmbeddedResource Remove="TrackTemplate\ValueObjects\**" />
<None Remove="TrackTemplate\ValueObjects\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="SJZY.LoggerCenter.HttpApi" Version="7.0.5"/>
<PackageReference Include="Volo.Abp.Autofac" Version="7.0.2"/>
<PackageReference Include="SJZY.UserCenter.HttpApi" Version="3.0.3-alpha8"/>
<PackageReference Include="SJZY.Expand.CAP" Version="7.8.0"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="SJZY.LoggerCenter.HttpApi" Version="7.0.5"/>
<PackageReference Include="Volo.Abp.Autofac" Version="7.0.2"/>
<PackageReference Include="SJZY.UserCenter.HttpApi" Version="3.0.3-alpha8"/>
<PackageReference Include="SJZY.Expand.CAP" Version="7.8.0"/>
</ItemGroup>
<ItemGroup>
<Folder Include="TrackPushRecordDetails\ValueObjects\" />
<Folder Include="TrackPushRecord\ValueObjects\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SJZY.Track.Domain\SJZY.Track.Domain.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SJZY.Track.Domain\SJZY.Track.Domain.csproj"/>
</ItemGroup>
</Project>

View File

@ -15,8 +15,8 @@ namespace SJZY.Track.Infrastructure;
/// 仓储模块
/// </summary>
[DependsOn(typeof(AbpAutofacModule))]
[DependsOn(typeof(SJZYTrackDomainModule))]
public class SJZYTrackInfrastructureModule : AbpModule
[DependsOn(typeof(SjzyTrackDomainModule))]
public class SjzyTrackInfrastructureModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
@ -28,7 +28,7 @@ public class SJZYTrackInfrastructureModule : AbpModule
{
new()
{
ConnectionString = configuration["ConnectionStrings:DefaultConnection"],
ConnectionString = configuration["ConnectionStrings:DefaultConnection"]!,
DbType = DbType.MySql,
IsAutoCloseConnection = true,
ConfigId = "default", OpenSqlLog = true
@ -39,10 +39,10 @@ public class SJZYTrackInfrastructureModule : AbpModule
context.Services.AddElasticSearch(options =>
{
options.NodeUrls = configuration.GetSection("ElasticSearch:NodeUrls").Get<List<string>>();
options.LoginName = configuration["ElasticSearch:LoginName"];
options.Password = configuration["ElasticSearch:Password"];
options.Base64PassPassword = configuration["ElasticSearch:Base64PassPassword"];
options.NodeUrls = configuration.GetSection("ElasticSearch:NodeUrls").Get<List<string>>()!;
options.LoginName = configuration["ElasticSearch:LoginName"]!;
options.Password = configuration["ElasticSearch:Password"]!;
options.Base64PassPassword = configuration["ElasticSearch:Base64PassPassword"]!;
});
}

View File

@ -36,13 +36,13 @@ namespace SJZY.Track.Infrastructure.TrackPushRecord.Entitys
/// 推送内容
/// </summary>
[SugarColumn(ColumnName = "PushContent")]
public string PushContent { get; set; }
public string PushContent { get; set; } = null!;
/// <summary>
/// 接口通请求id
/// </summary>
[SugarColumn(ColumnName = "RequestId")]
public string RequestId { get; set; }
public string RequestId { get; set; } = null!;
/// <summary>
/// 服务商id
@ -54,6 +54,6 @@ namespace SJZY.Track.Infrastructure.TrackPushRecord.Entitys
/// 推送轨迹总数
/// </summary>
[SugarColumn(ColumnName = "TrackTotal")]
public string TrackTotal { get; set; }
public int TrackTotal { get; set; }
}
}

View File

@ -1,29 +0,0 @@
using SJZY.Track.Application.Contract.Dtos.Demo;
using SJZY.Track.Application.Services.Demo;
namespace SJZY.OpenApi.Test.Demo
{
public class DemoTest : TestModuleTestBase
{
#region 构造函数
private InterFaceDemoService _interFaceDemoService;
public DemoTest()
{
_interFaceDemoService = GetRequiredService<InterFaceDemoService>();
}
#endregion
[Fact]
public async Task Test()
{
var data = new DemoInput();
var res = await _interFaceDemoService.Edit(data);
Assert.NotNull(res);
}
}
}

View File

@ -13,22 +13,21 @@ using Volo.Abp.Modularity;
using Volo.Abp.Threading;
[assembly: HostingStartup(typeof(SJZY.Expand.ABP.Core.HostingStartup))]
namespace SJZY.Track.Test;
[DependsOn(
typeof(AbpAspNetCoreTestBaseModule),
typeof(AbpAutofacModule),
typeof(AbpAuthorizationModule),
typeof(SJZYTrackInfrastructureModule),
typeof(ApplicationModule),
typeof(SJZYTrackApiModule),
typeof(SjzyTrackInfrastructureModule),
typeof(SjzyTrackApplicationModule),
typeof(SjzyTrackApiModule),
typeof(AbpHttpClientModule) //添加abp的http代理模块
)]
[assembly: HostingStartup(typeof(Expand.ABP.Core.HostingStartup))]
public class TestModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAlwaysAllowAuthorization();