diff --git a/src/SJZY.Track.Api/Program.cs b/src/SJZY.Track.Api/Program.cs index 9d6d0ed4..db266046 100644 --- a/src/SJZY.Track.Api/Program.cs +++ b/src/SJZY.Track.Api/Program.cs @@ -10,10 +10,10 @@ try .AddConfigurationContainer() .AddOptionsFromConfiguration() .UseSerilogDefault() - .Host.AddAppSettingsSecretsJson() + .Host.AddAppSettingsSecretsJson() .UseAutofac(); - await builder.AddApplicationAsync(); + await builder.AddApplicationAsync(); var app = builder.Build(); await app.InitializeApplicationAsync(); diff --git a/src/SJZY.Track.Api/SJZY.Track.Api.csproj b/src/SJZY.Track.Api/SJZY.Track.Api.csproj index 0dd07648..a2a8fad3 100644 --- a/src/SJZY.Track.Api/SJZY.Track.Api.csproj +++ b/src/SJZY.Track.Api/SJZY.Track.Api.csproj @@ -1,34 +1,26 @@  - - net7.0 - enable - enable - True - Linux - ..\.. - + - - - - - - + + net7.0 + True + Linux + ..\.. + - - - - - - - + + + + + + + + + + + + - - - - - - diff --git a/src/SJZY.Track.Api/SJZYTrackApiModule.cs b/src/SJZY.Track.Api/SjzyTrackApiModule.cs similarity index 96% rename from src/SJZY.Track.Api/SJZYTrackApiModule.cs rename to src/SJZY.Track.Api/SjzyTrackApiModule.cs index 07bb3fee..443495ce 100644 --- a/src/SJZY.Track.Api/SJZYTrackApiModule.cs +++ b/src/SJZY.Track.Api/SjzyTrackApiModule.cs @@ -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) { diff --git a/src/SJZY.Track.Application.Contract/Dtos/Demo/ComplexAutomapperDemoInput.cs b/src/SJZY.Track.Application.Contract/Dtos/Demo/ComplexAutomapperDemoInput.cs deleted file mode 100644 index f2162eb5..00000000 --- a/src/SJZY.Track.Application.Contract/Dtos/Demo/ComplexAutomapperDemoInput.cs +++ /dev/null @@ -1,85 +0,0 @@ -namespace SJZY.Track.Application.Contract.Dtos.Demo -{ - /// - /// automapper 复杂转换样例 - /// - public class ComplexAutomapperDemoInput - { - /// - /// 编号 - /// - public int Id { get; set; } - - /// - /// 操作类型 - /// - public OptionType OptionType { get; set; } - - /// - /// 描述 - /// - public string Description { get; set; } - - /// - /// 性别 - /// - public Gender Gender { get; set; } - - /// - /// 用户信息 - /// - public UserInfoInput UserInfo { get; set; } - - /// - /// 用户角色 - /// - public List UserRoleInputList { get; set; } - - /// - /// 拓展演示,目前大家共同约定,暂时不使用充血模型 - /// - /// - public string GetAddress() - { - return "辽宁省沈阳市..."; - } - } - - public class ComplexAutomapperDemoOutput - { - /// - /// 编号 - /// - public int Id { get; set; } - - /// - /// 性别 - /// - public string Gender { get; set; } - - /// - /// 描述 - /// - public string Description { get; set; } - - /// - /// 年龄 - /// - public int Age { get; set; } - - /// - /// qq号码 - /// - public string QQ { get; set; } - - /// - /// 地址 - /// - public string Address { get; set; } - - /// - /// 角色编号 - /// - public int[] RoleIds { get; set; } - } -} \ No newline at end of file diff --git a/src/SJZY.Track.Application.Contract/Dtos/Demo/DemoDetailInput.cs b/src/SJZY.Track.Application.Contract/Dtos/Demo/DemoDetailInput.cs deleted file mode 100644 index e80c4745..00000000 --- a/src/SJZY.Track.Application.Contract/Dtos/Demo/DemoDetailInput.cs +++ /dev/null @@ -1,48 +0,0 @@ -namespace SJZY.Track.Application.Contract.Dtos.Demo -{ - public class DemoDetailSaveInput - { - /// - /// - /// - public int Id { get; set; } - - /// - /// 姓名 - /// - public string Name { get; set; } - - /// - /// 年龄 - /// - public int Age { get; set; } - - /// - /// 描述 - /// - public string Description { get; set; } - - /// - /// 详情合集 - /// - public List DemoDetailList { get; set; } - } - - public class DemoDetailInput - { - /// - /// Id - /// - public int Id { get; set; } - - /// - /// t_demo.id - /// - public int DemoId { get; set; } - - /// - /// 一些说明.. - /// - public string OtherInfo { get; set; } - } -} \ No newline at end of file diff --git a/src/SJZY.Track.Application.Contract/Dtos/Demo/DemoInput.cs b/src/SJZY.Track.Application.Contract/Dtos/Demo/DemoInput.cs deleted file mode 100644 index 87f95820..00000000 --- a/src/SJZY.Track.Application.Contract/Dtos/Demo/DemoInput.cs +++ /dev/null @@ -1,42 +0,0 @@ -namespace SJZY.Track.Application.Contract.Dtos.Demo -{ - public class DemoInput - { - /// - /// 操作类型 - /// - public OptionType Option { get; set; } - - /// - /// - /// - public int Id { get; set; } - - /// - /// 姓名 - /// - public string Name { get; set; } - - /// - /// 年龄 - /// - public int Age { get; set; } - - /// - /// 描述 - /// - public string Description { get; set; } - - //以下两个属性用来说明类型转换 - - /// - /// 创建人id - /// - public string CreateUserId { get; set; } - - /// - /// 创建时间 - /// - public string CreateTime { get; set; } - } -} \ No newline at end of file diff --git a/src/SJZY.Track.Application.Contract/Dtos/Demo/ExcelImportOuput.cs b/src/SJZY.Track.Application.Contract/Dtos/Demo/ExcelImportOuput.cs deleted file mode 100644 index b2afbc57..00000000 --- a/src/SJZY.Track.Application.Contract/Dtos/Demo/ExcelImportOuput.cs +++ /dev/null @@ -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; } -} \ No newline at end of file diff --git a/src/SJZY.Track.Application.Contract/Dtos/Demo/GetDemoListByPageInput.cs b/src/SJZY.Track.Application.Contract/Dtos/Demo/GetDemoListByPageInput.cs deleted file mode 100644 index a49e420a..00000000 --- a/src/SJZY.Track.Application.Contract/Dtos/Demo/GetDemoListByPageInput.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace SJZY.Track.Application.Contract.Dtos.Demo; - -public class GetDemoListByPageInput : PageInfoInput -{ - /// - /// 姓名 - /// - public string Name { get; set; } -} \ No newline at end of file diff --git a/src/SJZY.Track.Application.Contract/Dtos/Demo/GetDemoListByPageOutput.cs b/src/SJZY.Track.Application.Contract/Dtos/Demo/GetDemoListByPageOutput.cs deleted file mode 100644 index fd91bc62..00000000 --- a/src/SJZY.Track.Application.Contract/Dtos/Demo/GetDemoListByPageOutput.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace SJZY.Track.Application.Contract.Dtos.Demo -{ - public class GetDemoListByPageOutput - { - /// - /// - /// - public int Id { get; set; } - - /// - /// 姓名 - /// - public string Name { get; set; } - - /// - /// 年龄 - /// - public int Age { get; set; } - - /// - /// 描述 - /// - public string Description { get; set; } - - public DateTime CreateTime { get; set; } - } -} \ No newline at end of file diff --git a/src/SJZY.Track.Application.Contract/Dtos/Demo/MyCustomerResultOutput.cs b/src/SJZY.Track.Application.Contract/Dtos/Demo/MyCustomerResultOutput.cs deleted file mode 100644 index f1a5288c..00000000 --- a/src/SJZY.Track.Application.Contract/Dtos/Demo/MyCustomerResultOutput.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace SJZY.Track.Application.Contract.Dtos.Demo -{ - public class MyCustomerResultOutput - { - public string Code { get; set; } - - public string Message { get; set; } - } -} \ No newline at end of file diff --git a/src/SJZY.Track.Application.Contract/Dtos/Demo/OssUploadOutput.cs b/src/SJZY.Track.Application.Contract/Dtos/Demo/OssUploadOutput.cs deleted file mode 100644 index 68b3abcf..00000000 --- a/src/SJZY.Track.Application.Contract/Dtos/Demo/OssUploadOutput.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace SJZY.Track.Application.Contract.Dtos.Demo -{ - public class OssUploadOutput - { - /// - /// 文件key - /// - public string Key { get; set; } - - /// - /// 文件路径 - /// - public string Url { get; set; } - } -} \ No newline at end of file diff --git a/src/SJZY.Track.Application.Contract/Dtos/Demo/RemoteDemoInput.cs b/src/SJZY.Track.Application.Contract/Dtos/Demo/RemoteDemoInput.cs deleted file mode 100644 index 2f43a8fa..00000000 --- a/src/SJZY.Track.Application.Contract/Dtos/Demo/RemoteDemoInput.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace SJZY.Track.Application.Contract.Dtos -{ - public class RemoteDemoInput - { - /// - /// 当前时间 - /// - public DateTime CurrentTime { get; set; } - } -} \ No newline at end of file diff --git a/src/SJZY.Track.Application.Contract/Dtos/Demo/RemoteDemoOutput.cs b/src/SJZY.Track.Application.Contract/Dtos/Demo/RemoteDemoOutput.cs deleted file mode 100644 index 0cd20796..00000000 --- a/src/SJZY.Track.Application.Contract/Dtos/Demo/RemoteDemoOutput.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace SJZY.Track.Application.Contract.Dtos -{ - public class RemoteDemoOutput - { - public string Context { get; set; } - } -} \ No newline at end of file diff --git a/src/SJZY.Track.Application.Contract/Dtos/Demo/SwaggerDemoInput.cs b/src/SJZY.Track.Application.Contract/Dtos/Demo/SwaggerDemoInput.cs deleted file mode 100644 index eefc7559..00000000 --- a/src/SJZY.Track.Application.Contract/Dtos/Demo/SwaggerDemoInput.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.ComponentModel; -using System.Text.Json.Serialization; - -namespace SJZY.Track.Application.Contract.Dtos.Demo -{ - public class SwaggerDemoInput - { - /// - /// 年龄 - /// - /// 18 这里可以写一些初始值 - public int Age { get; set; } - - /// - /// 姓名 - /// - public string Name { get; set; } - - /// - /// 性别(枚举的展示样例) - /// - public Gender Gender { get; set; } - - /// - /// 隐藏属性 - /// - [JsonIgnore] - public int MyProperty { get; set; } - } - - public enum Gender - { - [Description("纯爷们")] 男 = 2, - - [Description("大姑娘")] 女 = 5, - - [Description("你憋问")] 未知 = 8 - } -} \ No newline at end of file diff --git a/src/SJZY.Track.Application.Contract/Dtos/Demo/ValidateExecuteInput.cs b/src/SJZY.Track.Application.Contract/Dtos/Demo/ValidateExecuteInput.cs deleted file mode 100644 index 2de0afdf..00000000 --- a/src/SJZY.Track.Application.Contract/Dtos/Demo/ValidateExecuteInput.cs +++ /dev/null @@ -1,97 +0,0 @@ -namespace SJZY.Track.Application.Contract.Dtos.Demo -{ - public class ValidateExecuteInput - { - /// - /// 操作类型 - /// - public OptionType Option { get; set; } - - /// - /// 主键编号 - /// - public int Id { get; set; } - - /// - /// 雪花ID - /// - public long SnowId { get; set; } - - /// - /// 登录账号 - /// - public string LoginName { get; set; } - - /// - /// 登录密码 - /// - public string? PassWord { get; set; } - - /// - /// 登录密码确认 - /// - public string PassWordAgain { get; set; } - - /// - /// 最大金额额度 - /// - public decimal TotalQuota { get; set; } - - /// - /// 最大数量 - /// - public int MaxCount { get; set; } - - /// - /// 最小数量 - /// - public int MiniCount { get; set; } - - /// - /// 用户信息 - /// - public UserInfoInput UserInfoInput { get; set; } - - /// - /// 用户角色 - /// - public List UserRoleInputList { get; set; } - } - - public class UserInfoInput - { - /// - /// 生日 - /// - public DateTime BirthDay { get; set; } - - /// - /// qq号码 - /// - public string QQ { get; set; } - - /// - /// 电子邮箱 - /// - public string Email { get; set; } - - /// - /// 用户姓名 - /// - public string UserName { get; set; } - } - - - public class UserRoleInput - { - /// - /// 角色编号 - /// - public int Id { get; set; } - - /// - /// 角色名称 - /// - public string Name { get; set; } - } -} \ No newline at end of file diff --git a/src/SJZY.Track.Application.Contract/Dtos/Demo/ValidateExecuteOutput.cs b/src/SJZY.Track.Application.Contract/Dtos/Demo/ValidateExecuteOutput.cs deleted file mode 100644 index 1ea87d0f..00000000 --- a/src/SJZY.Track.Application.Contract/Dtos/Demo/ValidateExecuteOutput.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace SJZY.Track.Application.Contract.Dtos.Demo -{ - public class ValidateExecuteOutput - { - } -} \ No newline at end of file diff --git a/src/SJZY.Track.Application.Contract/SJZY.Track.Application.Contract.csproj b/src/SJZY.Track.Application.Contract/SJZY.Track.Application.Contract.csproj index 1d376964..a7a570d0 100644 --- a/src/SJZY.Track.Application.Contract/SJZY.Track.Application.Contract.csproj +++ b/src/SJZY.Track.Application.Contract/SJZY.Track.Application.Contract.csproj @@ -1,14 +1,14 @@ + + net7.0 - enable - enable 0.0.2 - - + + diff --git a/src/SJZY.Track.Application.Contract/Services/IRemoteDemoService.cs b/src/SJZY.Track.Application.Contract/Services/IRemoteDemoService.cs deleted file mode 100644 index 841cae19..00000000 --- a/src/SJZY.Track.Application.Contract/Services/IRemoteDemoService.cs +++ /dev/null @@ -1,13 +0,0 @@ -using SJZY.Track.Application.Contract.Dtos; -using Volo.Abp; -using Volo.Abp.DependencyInjection; - -namespace SJZY.Track.Application.Contract.Services; - -/// -/// 客户端连接测试接口 -/// -public interface IRemoteDemoService : IRemoteService, IScopedDependency -{ - Task> ConnectionTest(RemoteDemoInput input); -} \ No newline at end of file diff --git a/src/SJZY.Track.Application.Contract/SjzyTrackApplicationContractModule.cs b/src/SJZY.Track.Application.Contract/SjzyTrackApplicationContractModule.cs new file mode 100644 index 00000000..0da04423 --- /dev/null +++ b/src/SJZY.Track.Application.Contract/SjzyTrackApplicationContractModule.cs @@ -0,0 +1,10 @@ +using Volo.Abp.Modularity; + +namespace SJZY.Track.Application.Contract; + +public class SjzyTrackApplicationContractModule : AbpModule +{ + public override void PreConfigureServices(ServiceConfigurationContext context) + { + } +} \ No newline at end of file diff --git a/src/SJZY.Track.Application.Contract/TrackHttpApiModule.cs b/src/SJZY.Track.Application.Contract/TrackHttpApiModule.cs deleted file mode 100644 index a76ed6da..00000000 --- a/src/SJZY.Track.Application.Contract/TrackHttpApiModule.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Volo.Abp.Modularity; - -namespace SJZY.Track.Application.Contract -{ - public class TrackHttpApiModule : AbpModule - { - public override void PreConfigureServices(ServiceConfigurationContext context) - { - } - } -} \ No newline at end of file diff --git a/src/SJZY.Track.Application/AutoMapper/AutoMapperProfile.cs b/src/SJZY.Track.Application/AutoMapper/AutoMapperProfile.cs deleted file mode 100644 index 87914d8e..00000000 --- a/src/SJZY.Track.Application/AutoMapper/AutoMapperProfile.cs +++ /dev/null @@ -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>(MemberList.None); - - CreateMap(MemberList.None).ReverseMap(); - CreateMap, UnifyPageResultDto>(MemberList.None) - .ReverseMap(); - /* - 代码说明: - MemberList.None的意思是,忽略源对象和目标对象的属性匹配检查,其他可选值:MemberList.Source(检查是否映射了所有源成员)、MemberList.Destination(检查是否映射了所有目标成员) - .ReverseMap()的意思是配置双向调用关系,既一行代码既支持从 GetDemoListByPageInput -> DemoValueObject 的映射,同时也支持从 DemoValueObject -> GetDemoListByPageInput 的映射 - - - 如果对一对模型多次配置规则,会以最后一次为准,配置了这样规则后,最终执行结果是 Name + 444 - CreateMap().ForMember(dest => dest.Description, opt => opt.MapFrom(m => m.Name + "22")); - CreateMap().ForMember(dest => dest.Description, opt => opt.MapFrom(m => m.Name + "444")); - - */ - - CreateMap(MemberList.None).ReverseMap(); - CreateMap(MemberList.None); - CreateMap(MemberList.None).ReverseMap(); - } -} \ No newline at end of file diff --git a/src/SJZY.Track.Application/AutoMapper/DemoAutoMapperProfile.cs b/src/SJZY.Track.Application/AutoMapper/DemoAutoMapperProfile.cs deleted file mode 100644 index ba28b16e..00000000 --- a/src/SJZY.Track.Application/AutoMapper/DemoAutoMapperProfile.cs +++ /dev/null @@ -1,44 +0,0 @@ -using AutoMapper; -using SJZY.Expand.ABP.Core.PublicMethords; -using SJZY.Track.Application.Contract.Dtos.Demo; - -namespace SJZY.Track.Application.AutoMapper -{ - /// - /// 稍复杂的配置类 - /// - internal class DemoAutoMapperProfile : Profile - { - public DemoAutoMapperProfile() - { - CreateMap(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; - } - } -} \ No newline at end of file diff --git a/src/SJZY.Track.Application/GlobalUsing.cs b/src/SJZY.Track.Application/GlobalUsing.cs index e21f1746..e4968bf8 100644 --- a/src/SJZY.Track.Application/GlobalUsing.cs +++ b/src/SJZY.Track.Application/GlobalUsing.cs @@ -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; \ No newline at end of file diff --git a/src/SJZY.Track.Application/GlobalUsings.cs b/src/SJZY.Track.Application/GlobalUsings.cs deleted file mode 100644 index 63eef9f8..00000000 --- a/src/SJZY.Track.Application/GlobalUsings.cs +++ /dev/null @@ -1,3 +0,0 @@ -// Global using directives - -global using SJZY.Track.Domain; \ No newline at end of file diff --git a/src/SJZY.Track.Application/SJZY.Track.Application.csproj b/src/SJZY.Track.Application/SJZY.Track.Application.csproj index 93d801c4..fa25c565 100644 --- a/src/SJZY.Track.Application/SJZY.Track.Application.csproj +++ b/src/SJZY.Track.Application/SJZY.Track.Application.csproj @@ -1,32 +1,21 @@  - - - - net7.0 - True - + - - - - - - - - + + net7.0 + True + - - - - - - - - + + + + + + - - - - + + + + diff --git a/src/SJZY.Track.Application/Services/Demo/InterFaceDemoService.cs b/src/SJZY.Track.Application/Services/Demo/InterFaceDemoService.cs deleted file mode 100644 index 39d63fc8..00000000 --- a/src/SJZY.Track.Application/Services/Demo/InterFaceDemoService.cs +++ /dev/null @@ -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; - -/// -/// 接口请求完整样例 -/// -[ApiExplorerSettings(GroupName = "Demo")] -public class InterFaceDemoService : ApplicationService -{ - #region 构造函数 - - private readonly IDemoRepository _demoRepository; - - public InterFaceDemoService(IDemoRepository demoRepository) - { - _demoRepository = demoRepository; - } - - #endregion - - #region 增删改 - - /// - /// 增删改 - /// - /// - /// - [HttpPost("InterFace/Edit")] - public async Task Edit(DemoInput input) - { - var res = new LongIdBaseDto(); - - if (input.Option == OptionType.新增) - { - var entity = ObjectMapper.Map(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 局部更新最佳实践 - - /// - /// 局部更新最佳实践 - /// - /// - /// - /// - [HttpPost("InterFace/UpdatePartColumns")] - public async Task 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 分页查询接口 - - /// - /// 分页查询 - /// - /// - /// - [HttpPost("InterFace/GetListByPage")] - public async Task> GetListByPage(GetDemoListByPageInput input) - { - //分页时返回值统一用 PageResultDto<> 类型 - var list = await _demoRepository.GetListByPage(input.PageSize, input.PageIndex, input.Name); - - var res = ObjectMapper.Map, UnifyPageResultDto>(list); - - return res; - } - - #endregion - - #region 入参转换 - - /// - /// 入参转换 - /// - /// - /// - [HttpPost("InterFace/InputToValueObject")] - public async Task> InputToValueObject(GetDemoListByPageInput input) - { - var obj = ObjectMapper.Map(input); - var list = await _demoRepository.InputToValueObject(obj); - - var res = ObjectMapper.Map, List>(list); - return res; - } - - #endregion - - #region 原生sql - - /// - /// 原生sql - /// - /// - /// - [HttpPost("InterFace/OriginalSql")] - public async Task> OriginalSql(DemoValueObject obj) - { - var list = await _demoRepository.OriginalSql(obj); - return list; - } - - #endregion - - #region 自定义返回结果格式 - - /// - /// 自定义返回结果格式 - /// - /// - /// - [HttpPost("Demo/CustomerResult")] - [CustomerResult] - public async Task GetListAsync() - { - /* - 说明: - 理论上我们有全公司级别的返回值约定,不管是前端调后端,还是后端微服务间的调用,都应完全遵循该规范。 - 但不排除有些特殊情况下,必须要返回自定义格式的场景。 - */ - - var res = new MyCustomerResultOutput(); - res.Code = "200"; - res.Message = "这是一个自定义返回结果"; - - return res; - } - - #endregion - - #region 约定类型下返回null - - /// - /// 约定类型下返回null - /// - /// - /// - [HttpPost("Demo/ReturnNull")] - public async Task ReturnNull() - { - MyCustomerResultOutput res = null; - return res; - } - - #endregion - - #region - - /// - /// 没有返回值 - /// - /// - /// - [HttpPost("Demo/WithoutReturnObject")] - public async Task WithoutReturnObject() - { - return null; - } - - #endregion - - #region 主从关系实体存储 - - /// - /// 主从关系实体存储 - /// - /// - /// - [HttpPost("InterFace/EntityRelationSave")] - public async Task EntityRelationSave(DemoDetailSaveInput input) - { - var obj = ObjectMapper.Map(input); - var res = await _demoRepository.EntityRelationSave(obj); - - return new UnifyResultDto(res); - } - - #endregion - - #region 数据缓存 - - /// - /// 数据缓存 - /// - /// - /// - [HttpPost("InterFace/GetDataCache")] - public async Task GetDataCache(IdBaseDto input) - { - var res = await _demoRepository.GetDataCache(input.Id); - return res; - } - - #endregion - - //[HttpPost("InterFace/AAAA")] - //public async Task AAAA() - //{ - // var result = await _httpClientProxy.Service.GetSystemTokenAsync("Track"); - - // return result; - //} -} \ No newline at end of file diff --git a/src/SJZY.Track.Application/ApplicationModule.cs b/src/SJZY.Track.Application/SjzyTrackApplicationModule.cs similarity index 83% rename from src/SJZY.Track.Application/ApplicationModule.cs rename to src/SJZY.Track.Application/SjzyTrackApplicationModule.cs index 94127ff2..97b9337f 100644 --- a/src/SJZY.Track.Application/ApplicationModule.cs +++ b/src/SJZY.Track.Application/SjzyTrackApplicationModule.cs @@ -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(options => { options.AddMaps(true); }); + Configure(options => { options.AddMaps(true); }); Configure(options => { - options.ConventionalControllers.Create(typeof(ApplicationModule).Assembly); //创建动态api + options.ConventionalControllers.Create(typeof(SjzyTrackApplicationModule).Assembly); //创建动态api }); //添加虚拟文件系统 Configure(options => { - options.FileSets.AddEmbedded("SJZY.Track.Application"); + options.FileSets.AddEmbedded("SJZY.Track.Application"); }); //添加多语言 diff --git a/src/SJZY.Track.Application/Validations/Demo/SimpleValidateInputValidation.cs b/src/SJZY.Track.Application/Validations/Demo/SimpleValidateInputValidation.cs deleted file mode 100644 index a14bc02f..00000000 --- a/src/SJZY.Track.Application/Validations/Demo/SimpleValidateInputValidation.cs +++ /dev/null @@ -1,67 +0,0 @@ -using FluentValidation; -using SJZY.Track.Application.Contract.Dtos.Demo; - -namespace SJZY.Track.Application.Validations.Demo -{ - public class SimpleValidateInputValidation : AbstractValidator, 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()); - } - } -} \ No newline at end of file diff --git a/src/SJZY.Track.Application/Validations/Demo/UserInfoInputValidation.cs b/src/SJZY.Track.Application/Validations/Demo/UserInfoInputValidation.cs deleted file mode 100644 index 68c7441b..00000000 --- a/src/SJZY.Track.Application/Validations/Demo/UserInfoInputValidation.cs +++ /dev/null @@ -1,13 +0,0 @@ -using FluentValidation; -using SJZY.Track.Application.Contract.Dtos.Demo; - -namespace SJZY.Track.Application.Validations.Demo -{ - public class UserInfoInputValidation : AbstractValidator, IValidationEnabled - { - public UserInfoInputValidation() - { - RuleFor(x => x.QQ).NotNull().WithMessage("QQ号码不能为空"); - } - } -} \ No newline at end of file diff --git a/src/SJZY.Track.Application/Validations/Demo/UserRoleInputValidation.cs b/src/SJZY.Track.Application/Validations/Demo/UserRoleInputValidation.cs deleted file mode 100644 index dda21ddf..00000000 --- a/src/SJZY.Track.Application/Validations/Demo/UserRoleInputValidation.cs +++ /dev/null @@ -1,13 +0,0 @@ -using FluentValidation; -using SJZY.Track.Application.Contract.Dtos.Demo; - -namespace SJZY.Track.Application.Validations.Demo -{ - public class UserRoleInputValidation : AbstractValidator, IValidationEnabled - { - public UserRoleInputValidation() - { - RuleFor(m => m.Id).GreaterThan(0).WithMessage("角色ID必须大于0!"); - } - } -} \ No newline at end of file diff --git a/src/SJZY.Track.Domain/IBasicRepository.cs b/src/SJZY.Track.Domain/IBasicRepository.cs index 8e9baed2..3824c2eb 100644 --- a/src/SJZY.Track.Domain/IBasicRepository.cs +++ b/src/SJZY.Track.Domain/IBasicRepository.cs @@ -10,7 +10,7 @@ public interface IBasicRepository : IBasicQuery where T : IAggregateRoot /// /// 要忽略更新的列 /// - Task UpdateAsync(T entity, Expression> ignoreColumns); + Task UpdateAsync(T entity, Expression>? ignoreColumns); /// /// update @@ -18,7 +18,7 @@ public interface IBasicRepository : IBasicQuery where T : IAggregateRoot /// /// 要更新的列 /// - Task UpdateColumnAsync(T entity, Expression> updateColumns); + Task UpdateColumnAsync(T entity, Expression>? updateColumns); /// /// update diff --git a/src/SJZY.Track.Domain/SJZY.Track.Domain.csproj b/src/SJZY.Track.Domain/SJZY.Track.Domain.csproj index aac0e12d..b1f4dc63 100644 --- a/src/SJZY.Track.Domain/SJZY.Track.Domain.csproj +++ b/src/SJZY.Track.Domain/SJZY.Track.Domain.csproj @@ -10,9 +10,5 @@ - - - - diff --git a/src/SJZY.Track.Domain/SJZYTrackDomainModule.cs b/src/SJZY.Track.Domain/SJZYTrackDomainModule.cs index e9c743d8..792e7844 100644 --- a/src/SJZY.Track.Domain/SJZYTrackDomainModule.cs +++ b/src/SJZY.Track.Domain/SJZYTrackDomainModule.cs @@ -2,6 +2,6 @@ namespace SJZY.Track.Domain; -public class SJZYTrackDomainModule : AbpModule +public class SjzyTrackDomainModule : AbpModule { } \ No newline at end of file diff --git a/src/SJZY.Track.Infrastructure/Repositories/BasicRepository.cs b/src/SJZY.Track.Infrastructure/Repositories/BasicRepository.cs index a776fd88..7480b9f3 100644 --- a/src/SJZY.Track.Infrastructure/Repositories/BasicRepository.cs +++ b/src/SJZY.Track.Infrastructure/Repositories/BasicRepository.cs @@ -12,14 +12,14 @@ namespace SJZY.Track.Infrastructure.Repositories; /// public class BasicRepository : BasicQuery, IBasicRepository where T : class, IAggregateRoot, new() { - public async Task UpdateAsync(T entity, Expression> ignoreColumns) + public async Task UpdateAsync(T entity, Expression>? ignoreColumns) { return await Context.Updateable(entity) .IgnoreColumnsIF(ignoreColumns != null, ignoreColumns) .ExecuteCommandHasChangeAsync(); } - public async Task UpdateColumnAsync(T entity, Expression> updateColumns) + public async Task UpdateColumnAsync(T entity, Expression>? updateColumns) { return await Context.Updateable(entity) .UpdateColumnsIF(updateColumns != null, updateColumns) @@ -40,15 +40,13 @@ public class BasicRepository : BasicQuery, IBasicRepository where T : c .ExecuteCommandHasChangeAsync(); } + // tips: required where public async Task SoftDeleteAsync(Expression> where) { if (!typeof(T).IsAssignableTo()) throw new BusinessException( message: $"实体没有实现{nameof(ISoftDeleteBasicEntity)}不能调用{nameof(SoftDeleteAsync)}"); - // tips: required where - if (where == default) return false; - return await Context.Updateable() .Where(where) .SetColumns(nameof(ISoftDeleteBasicEntity.IsDeleted), 1) diff --git a/src/SJZY.Track.Infrastructure/Repositories/TrackStatusRepository.cs b/src/SJZY.Track.Infrastructure/Repositories/TrackStatusRepository.cs index a9218613..bf0325bc 100644 --- a/src/SJZY.Track.Infrastructure/Repositories/TrackStatusRepository.cs +++ b/src/SJZY.Track.Infrastructure/Repositories/TrackStatusRepository.cs @@ -6,10 +6,6 @@ namespace SJZY.Track.Infrastructure.Repositories; public class TrackStatusRepository : BasicRepository, ITrackStatusRepository, IScopedDependency { - public TrackStatusRepository() - { - } - /// /// 获取轨迹状态明细 /// @@ -41,8 +37,7 @@ public class TrackStatusRepository : BasicRepository, ITrackS /// public async Task> GetPageTrackStatus(GetPageTrackStatusVO input) { - UnifyPageResultDto pagedList = new UnifyPageResultDto(); - pagedList = await Context.Queryable() + UnifyPageResultDto pagedList = await Context.Queryable() .LeftJoin((a, b) => a.SubSystemId == b.Id) .LeftJoin((a, b, c) => a.CreateUserId == c.Id) .LeftJoin((a, b, c, d) => a.UpdateUserId == d.Id) @@ -57,9 +52,10 @@ public class TrackStatusRepository : BasicRepository, 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, diff --git a/src/SJZY.Track.Infrastructure/SJZY.Track.Infrastructure.csproj b/src/SJZY.Track.Infrastructure/SJZY.Track.Infrastructure.csproj index f1e677f8..f9bee800 100644 --- a/src/SJZY.Track.Infrastructure/SJZY.Track.Infrastructure.csproj +++ b/src/SJZY.Track.Infrastructure/SJZY.Track.Infrastructure.csproj @@ -1,37 +1,20 @@  - - - net7.0 - True - preview - + + + net7.0 + True + preview + - - - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - + + + diff --git a/src/SJZY.Track.Infrastructure/SJZYTrackInfrastructureModule.cs b/src/SJZY.Track.Infrastructure/SJZYTrackInfrastructureModule.cs index c412b69c..048d60fb 100644 --- a/src/SJZY.Track.Infrastructure/SJZYTrackInfrastructureModule.cs +++ b/src/SJZY.Track.Infrastructure/SJZYTrackInfrastructureModule.cs @@ -15,8 +15,8 @@ namespace SJZY.Track.Infrastructure; /// 仓储模块 /// [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>(); - options.LoginName = configuration["ElasticSearch:LoginName"]; - options.Password = configuration["ElasticSearch:Password"]; - options.Base64PassPassword = configuration["ElasticSearch:Base64PassPassword"]; + options.NodeUrls = configuration.GetSection("ElasticSearch:NodeUrls").Get>()!; + options.LoginName = configuration["ElasticSearch:LoginName"]!; + options.Password = configuration["ElasticSearch:Password"]!; + options.Base64PassPassword = configuration["ElasticSearch:Base64PassPassword"]!; }); } diff --git a/src/SJZY.Track.Infrastructure/TrackPushRecord/Entitys/TrackPushRecordEntity.cs b/src/SJZY.Track.Infrastructure/TrackPushRecord/Entitys/TrackPushRecordEntity.cs index 32615bba..345e7335 100644 --- a/src/SJZY.Track.Infrastructure/TrackPushRecord/Entitys/TrackPushRecordEntity.cs +++ b/src/SJZY.Track.Infrastructure/TrackPushRecord/Entitys/TrackPushRecordEntity.cs @@ -36,13 +36,13 @@ namespace SJZY.Track.Infrastructure.TrackPushRecord.Entitys /// 推送内容 /// [SugarColumn(ColumnName = "PushContent")] - public string PushContent { get; set; } + public string PushContent { get; set; } = null!; /// /// 接口通请求id /// [SugarColumn(ColumnName = "RequestId")] - public string RequestId { get; set; } + public string RequestId { get; set; } = null!; /// /// 服务商id @@ -54,6 +54,6 @@ namespace SJZY.Track.Infrastructure.TrackPushRecord.Entitys /// 推送轨迹总数 /// [SugarColumn(ColumnName = "TrackTotal")] - public string TrackTotal { get; set; } + public int TrackTotal { get; set; } } } \ No newline at end of file diff --git a/test/SJZY.Track.Test/Demo/DemoTest.cs b/test/SJZY.Track.Test/Demo/DemoTest.cs deleted file mode 100644 index 47e60be3..00000000 --- a/test/SJZY.Track.Test/Demo/DemoTest.cs +++ /dev/null @@ -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(); - } - - #endregion - - [Fact] - public async Task Test() - { - var data = new DemoInput(); - - var res = await _interFaceDemoService.Edit(data); - - Assert.NotNull(res); - } - } -} \ No newline at end of file diff --git a/test/SJZY.Track.Test/TestModule.cs b/test/SJZY.Track.Test/TestModule.cs index 43bc8f71..6bace7fa 100644 --- a/test/SJZY.Track.Test/TestModule.cs +++ b/test/SJZY.Track.Test/TestModule.cs @@ -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();