change 结构调整
This commit is contained in:
parent
752f65b1e2
commit
37e225e456
@ -19,14 +19,15 @@ using Volo.Abp.Json;
|
||||
using Volo.Abp.Modularity;
|
||||
|
||||
[assembly: HostingStartup(typeof(HostingStartup))]
|
||||
|
||||
namespace SJZY.Track.Api
|
||||
{
|
||||
[DependsOn(
|
||||
typeof(AbpAutofacModule),
|
||||
typeof(SjzyAbpCodeModule),
|
||||
typeof(ApplicationModule),
|
||||
typeof(AbpAspNetCoreMvcModule),
|
||||
typeof(AbpAspNetCoreSerilogModule),
|
||||
typeof(ApplicationModule),
|
||||
typeof(SJZYTrackRepositoryModule)
|
||||
)]
|
||||
public class SJZYTrackApiModule : AbpModule
|
||||
@ -49,7 +50,9 @@ namespace SJZY.Track.Api
|
||||
//Json格式化全局处理
|
||||
context.Services.Configure<MvcNewtonsoftJsonOptions>(options =>
|
||||
{
|
||||
options.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver();//.DefaultContractResolver();
|
||||
options.SerializerSettings.ContractResolver =
|
||||
new Newtonsoft.Json.Serialization.
|
||||
CamelCasePropertyNamesContractResolver(); //.DefaultContractResolver();
|
||||
options.SerializerSettings.Converters.Add(new DateTimeJsonConverter("yyyy-MM-dd HH:mm:ss"));
|
||||
options.SerializerSettings.Converters.Add(new LongJsonConverter());
|
||||
});
|
||||
@ -59,7 +62,6 @@ namespace SJZY.Track.Api
|
||||
|
||||
|
||||
context.Services.AddRedis();
|
||||
|
||||
}
|
||||
|
||||
public override void OnApplicationInitialization(ApplicationInitializationContext context)
|
||||
@ -79,6 +81,7 @@ namespace SJZY.Track.Api
|
||||
app.UsePrometheus();
|
||||
|
||||
#region 启动提示
|
||||
|
||||
Console.WriteLine($@"
|
||||
+-------------------------------------------------------+
|
||||
| |
|
||||
@ -89,8 +92,8 @@ namespace SJZY.Track.Api
|
||||
| |
|
||||
+-------------------------------------------------------+
|
||||
");
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
using AutoMapper;
|
||||
using SJZY.Track.Application.Dtos.Demo;
|
||||
using SJZY.Track.Domain.DemoAggregate;
|
||||
using SJZY.Track.Domain.DemoAggregate.Dtos;
|
||||
using SJZY.Track.Domain.Aggregates.DemoAggregate;
|
||||
using SJZY.Track.Domain.Dtos.Demo;
|
||||
|
||||
namespace SJZY.Track.Application.AutoMapper;
|
||||
|
||||
@ -12,7 +12,8 @@ internal class AutoMapperProfile : Profile
|
||||
CreateMap<UnifyPageResultDto<DemoEntity>, UnifyPageResultDto<GetDemoListByPageOutput>>(MemberList.None);
|
||||
|
||||
CreateMap<GetDemoListByPageInput, DemoValueObject>(MemberList.None).ReverseMap();
|
||||
CreateMap<UnifyPageResultDto<GetDemoListByPageInput>, UnifyPageResultDto<DemoValueObject>>(MemberList.None).ReverseMap();
|
||||
CreateMap<UnifyPageResultDto<GetDemoListByPageInput>, UnifyPageResultDto<DemoValueObject>>(MemberList.None)
|
||||
.ReverseMap();
|
||||
/*
|
||||
代码说明:
|
||||
MemberList.None的意思是,忽略源对象和目标对象的属性匹配检查,其他可选值:MemberList.Source(检查是否映射了所有源成员)、MemberList.Destination(检查是否映射了所有目标成员)
|
||||
@ -28,6 +29,5 @@ internal class AutoMapperProfile : Profile
|
||||
CreateMap<DemoEntity, DemoInput>(MemberList.None).ReverseMap();
|
||||
CreateMap<DemoEntity, GetDemoListByPageOutput>(MemberList.None);
|
||||
CreateMap<DemoEntity, DemoDetailSaveInput>(MemberList.None).ReverseMap();
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,22 +1,21 @@
|
||||
using AutoMapper;
|
||||
using SJZY.Track.Application.Dtos.TrackTemplates;
|
||||
using SJZY.Track.Domain.TrackTemplateAggregate;
|
||||
using SJZY.Track.Domain.TrackTemplateAggregate.Dtos;
|
||||
using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
|
||||
using SJZY.Track.Domain.Dtos.TrackTemplate;
|
||||
|
||||
namespace SJZY.Track.Application.AutoMapper
|
||||
namespace SJZY.Track.Application.AutoMapper;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹模版自动映射
|
||||
/// </summary>
|
||||
public class TrackTemplateAutoMapperProfile : Profile
|
||||
{
|
||||
/// <summary>
|
||||
/// 轨迹模版自动映射
|
||||
/// </summary>
|
||||
public class TrackTemplateAutoMapperProfile : Profile
|
||||
public TrackTemplateAutoMapperProfile()
|
||||
{
|
||||
public TrackTemplateAutoMapperProfile()
|
||||
{
|
||||
CreateMap<GetTrackTemplateDetailVO, GetTrackTemplateDetailDto>(MemberList.None);
|
||||
CreateMap<GetTrackTemplateDetailVO, GetTrackTemplateDetailDto>(MemberList.None);
|
||||
|
||||
//CreateMap<UnifyResultDto<GetTrackTemplateDetailVO>, UnifyResultDto<GetTrackTemplateDetailDto>>(MemberList.None);
|
||||
//CreateMap<UnifyResultDto<GetTrackTemplateDetailVO>, UnifyResultDto<GetTrackTemplateDetailDto>>(MemberList.None);
|
||||
|
||||
CreateMap<EditTrackTemplateContentInput, TrackTemplateContentEntity>(MemberList.None);
|
||||
}
|
||||
CreateMap<EditTrackTemplateContentInput, TrackTemplateContentEntity>(MemberList.None);
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
|
||||
namespace SJZY.Track.Application.Dtos.ProvideServices;
|
||||
|
||||
@ -22,7 +23,6 @@ public class CreateOrderInput
|
||||
public OrderDetails Details { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class OrderTemplateInfo
|
||||
{
|
||||
/// <summary>
|
||||
@ -43,22 +43,22 @@ public class OrderDetails
|
||||
/// 目的港口
|
||||
/// </summary>
|
||||
public string? ArrivalPort { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 起运港口
|
||||
/// </summary>
|
||||
public string? LeavePort { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 目的国家,必填
|
||||
/// </summary>
|
||||
public string ArrivalCountry { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 起运国家,必填
|
||||
/// </summary>
|
||||
public string LeaveCountry { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 目的城市,必填
|
||||
/// </summary>
|
||||
@ -68,7 +68,7 @@ public class OrderDetails
|
||||
/// 起运城市,必填
|
||||
/// </summary>
|
||||
public string LeaveCity { get; set; }
|
||||
|
||||
|
||||
public List<FligthInfo> FligthInfos { get; set; }
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ public class FligthInfo
|
||||
/// 航班号
|
||||
/// </summary>
|
||||
public string FlightNo { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 班期
|
||||
/// </summary>
|
||||
|
||||
@ -1,26 +1,15 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
|
||||
namespace SJZY.Track.Application.Dtos.ProvideServices;
|
||||
|
||||
public class LinkOrderInput
|
||||
{
|
||||
/// <summary>
|
||||
/// false解绑,true关联,必填
|
||||
/// </summary>
|
||||
public bool IsLink { get; set; }
|
||||
|
||||
public NoInfo NoInfo { get; set; }
|
||||
|
||||
public List<NoInfo> LinkedOrderInfos { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class NoInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单类型
|
||||
/// </summary>
|
||||
public int NoType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号
|
||||
/// </summary>
|
||||
[Required]
|
||||
[MaxLength(100)]
|
||||
public string OrderNo { get; set; }
|
||||
}
|
||||
@ -1,79 +1,45 @@
|
||||
using SJZY.Expand.ABP.Core.Common;
|
||||
using SJZY.Track.Application.Dtos.Demo;
|
||||
using SJZY.Track.Domain.DemoAggregate;
|
||||
using SJZY.Track.Domain.DemoAggregate.Dtos;
|
||||
using SJZY.Track.Domain.Aggregates.DemoAggregate;
|
||||
using SJZY.Track.Domain.Dtos.Demo;
|
||||
|
||||
namespace SJZY.Track.Application.Services.Demo
|
||||
namespace SJZY.Track.Application.Services.Demo;
|
||||
|
||||
/// <summary>
|
||||
/// 接口请求完整样例
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "Demo")]
|
||||
public class InterFaceDemoService : ApplicationService
|
||||
{
|
||||
/// <summary>
|
||||
/// 接口请求完整样例
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "Demo")]
|
||||
public class InterFaceDemoService : ApplicationService
|
||||
#region 构造函数
|
||||
|
||||
private readonly IDemoRepository _demoRepository;
|
||||
|
||||
public InterFaceDemoService(IDemoRepository demoRepository)
|
||||
{
|
||||
#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.新增)
|
||||
{
|
||||
_demoRepository = demoRepository;
|
||||
var entity = ObjectMapper.Map<DemoInput, DemoEntity>(input);
|
||||
res.Id = await _demoRepository.InsertReturnIdentityAsync(entity);
|
||||
}
|
||||
#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)
|
||||
else if (input.Option == OptionType.修改 || input.Option == OptionType.删除)
|
||||
{
|
||||
var demoInfo = await _demoRepository.GetById1(input.Id);
|
||||
if (demoInfo == null)
|
||||
@ -82,152 +48,204 @@ namespace SJZY.Track.Application.Services.Demo
|
||||
throw new BusinessException(message: "未找到指定编号下的数据");
|
||||
}
|
||||
|
||||
//更新同时忽略某几项参数
|
||||
await _demoRepository.UpdatePartColumns(demoInfo);
|
||||
res.Id = demoInfo.Id;
|
||||
if (input.Option == OptionType.删除)
|
||||
{
|
||||
//await _demoRepository.DeleteAsync(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;
|
||||
//软删除
|
||||
demoInfo.IsDeleted = true;
|
||||
await _demoRepository.UpdateAsync(demoInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
var entity = ObjectMapper.Map(input, demoInfo);
|
||||
await _demoRepository.UpdateAsync(entity);
|
||||
}
|
||||
}
|
||||
|
||||
#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;
|
||||
//}
|
||||
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;
|
||||
//}
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
using Newtonsoft.Json;
|
||||
using SJZY.Track.Application.Dtos.ProvideServices;
|
||||
using SJZY.Track.Domain;
|
||||
using SJZY.Track.Domain.OrderAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.UserCenter.HttpApi.Services;
|
||||
|
||||
namespace SJZY.Track.Application.Services.ProvideServices;
|
||||
@ -10,13 +10,15 @@ namespace SJZY.Track.Application.Services.ProvideServices;
|
||||
/// 订单服务
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "提供接口")]
|
||||
public class OrderService: ApplicationService
|
||||
public class OrderService : ApplicationService
|
||||
{
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
private readonly IBasicQuery<OrderLinkEntity> _orderLinkQuery;
|
||||
|
||||
public OrderService(IOrderRepository orderRepository)
|
||||
public OrderService(IOrderRepository orderRepository, IBasicQuery<OrderLinkEntity> orderLinkQuery)
|
||||
{
|
||||
_orderRepository = orderRepository;
|
||||
_orderLinkQuery = orderLinkQuery;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -44,10 +46,10 @@ public class OrderService: ApplicationService
|
||||
};
|
||||
|
||||
using var tran = TransactionHelper.GetReadCommitted();
|
||||
|
||||
|
||||
// 创建订单
|
||||
var orderId = await _orderRepository.InsertReturnIdentityAsync(order);
|
||||
|
||||
|
||||
// 创建订单模板
|
||||
var templates = input.Templates.Select(x => new OrderTemplateEntity
|
||||
{
|
||||
@ -60,7 +62,7 @@ public class OrderService: ApplicationService
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 关联订单
|
||||
/// </summary>
|
||||
@ -69,13 +71,23 @@ public class OrderService: ApplicationService
|
||||
[HttpPost("Order/Link")]
|
||||
public async Task<bool> LinkOrderAsync(LinkOrderInput input)
|
||||
{
|
||||
// var distinctOrderNos = input.LinkedOrderInfos.Distinct().ToList();
|
||||
//
|
||||
//todo:去重
|
||||
var distinctOrderInfos = input.LinkedOrderInfos.Distinct().ToList();
|
||||
|
||||
if (await _orderRepository.IsAnyAsync(x => x.IsEqual(input.NoInfo)))
|
||||
{
|
||||
}
|
||||
|
||||
// var links = input.LinkedOrderInfos.Select(x => new OrderLinkEntity
|
||||
// {
|
||||
// LinkOrderId = x.,
|
||||
// OrderId = 0
|
||||
// })
|
||||
// OrderNo = x.OrderNo,
|
||||
// OrderType = x.NoType
|
||||
// }).ToList();
|
||||
//
|
||||
// foreach (var link in links)
|
||||
// {
|
||||
// if (await _orderLinkQuery.IsAnyAsync(x => x.))
|
||||
// }
|
||||
// _orderRepository.LinkOrderAsync();
|
||||
|
||||
return true;
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
using SJZY.Track.Application.Dtos.ProvideServices;
|
||||
using SJZY.Track.Domain;
|
||||
using SJZY.Track.Domain.OrderAggregate;
|
||||
using SJZY.Track.Domain.TrackTemplateAggregate;
|
||||
using SJZY.Track.Application.Dtos.ProvideServices;
|
||||
using SJZY.Track.Repository.TrackDetails;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
|
||||
|
||||
namespace SJZY.Track.Application.Services.ProvideServices;
|
||||
|
||||
|
||||
@ -1,72 +1,66 @@
|
||||
using SJZY.Track.Application.Dtos.TrackStatus;
|
||||
using SJZY.Track.Application.Dtos.TrackTemplates;
|
||||
using SJZY.Track.Domain.TrackStatusAggregate;
|
||||
using SJZY.Track.Domain.TrackTemplateAggregate;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SJZY.Track.Domain.Aggregates.TrackStatusAggregate;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace SJZY.Track.Application.Services.TrackStatus
|
||||
namespace SJZY.Track.Application.Services.TrackStatus;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹状态
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "轨迹状态")]
|
||||
[Route("/Track/Status")]
|
||||
public class TrackStatusService : ApplicationService, ITransientDependency
|
||||
{
|
||||
/// <summary>
|
||||
/// 轨迹状态
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "轨迹状态")]
|
||||
[Route("/Track/Status")]
|
||||
public class TrackStatusService : ApplicationService, ITransientDependency
|
||||
private readonly ITrackStatusRepository _trackStatusRepository;
|
||||
|
||||
public TrackStatusService(
|
||||
ITrackStatusRepository trackStatusRepository
|
||||
)
|
||||
{
|
||||
private readonly ITrackStatusRepository _trackStatusRepository;
|
||||
|
||||
public TrackStatusService(
|
||||
ITrackStatusRepository trackStatusRepository
|
||||
)
|
||||
{
|
||||
this._trackStatusRepository=trackStatusRepository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹状态编辑
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Edit")]
|
||||
public async Task<UnifyResultDto> EditAsync(EditTrackStatusInput input)
|
||||
{
|
||||
return input.Options switch
|
||||
{
|
||||
OptionType.新增 => await AddAsync(input),
|
||||
OptionType.修改 => await UpdateAsync(input),
|
||||
OptionType.删除 => await DeleteAsync(input),
|
||||
_ => throw new BusinessException(message: "当前操作动作不合法")
|
||||
};
|
||||
}
|
||||
|
||||
#region 私有方法
|
||||
private async Task<UnifyResultDto> AddAsync(EditTrackStatusInput input)
|
||||
{
|
||||
var entity = ObjectMapper.Map<EditTrackStatusInput, TrackStatusEntity>(input);
|
||||
var isTrue = await _trackStatusRepository.InsertAsync(entity);
|
||||
|
||||
return new UnifyResultDto("200", "新增成功", isTrue);
|
||||
}
|
||||
|
||||
private async Task<UnifyResultDto> UpdateAsync(EditTrackStatusInput input)
|
||||
{
|
||||
var templateEntity = await _trackStatusRepository.GetFirstAsync(a => a.Id == input.Id);
|
||||
ObjectMapper.Map(input, templateEntity);
|
||||
var isTrue = await _trackStatusRepository.UpdateAsync(templateEntity);
|
||||
|
||||
return new UnifyResultDto("200", "修改成功", isTrue);
|
||||
}
|
||||
|
||||
private async Task<UnifyResultDto> DeleteAsync(EditTrackStatusInput input)
|
||||
{
|
||||
var isTrue = await _trackStatusRepository.SoftDeleteAsync(x => x.Id == input.Id);
|
||||
|
||||
return new UnifyResultDto("200", "删除成功", isTrue);
|
||||
}
|
||||
#endregion
|
||||
this._trackStatusRepository = trackStatusRepository;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹状态编辑
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Edit")]
|
||||
public async Task<UnifyResultDto> EditAsync(EditTrackStatusInput input)
|
||||
{
|
||||
return input.Options switch
|
||||
{
|
||||
OptionType.新增 => await AddAsync(input),
|
||||
OptionType.修改 => await UpdateAsync(input),
|
||||
OptionType.删除 => await DeleteAsync(input),
|
||||
_ => throw new BusinessException(message: "当前操作动作不合法")
|
||||
};
|
||||
}
|
||||
|
||||
#region 私有方法
|
||||
|
||||
private async Task<UnifyResultDto> AddAsync(EditTrackStatusInput input)
|
||||
{
|
||||
var entity = ObjectMapper.Map<EditTrackStatusInput, TrackStatusEntity>(input);
|
||||
var isTrue = await _trackStatusRepository.InsertAsync(entity);
|
||||
|
||||
return new UnifyResultDto("200", "新增成功", isTrue);
|
||||
}
|
||||
|
||||
private async Task<UnifyResultDto> UpdateAsync(EditTrackStatusInput input)
|
||||
{
|
||||
var templateEntity = await _trackStatusRepository.GetFirstAsync(a => a.Id == input.Id);
|
||||
ObjectMapper.Map(input, templateEntity);
|
||||
var isTrue = await _trackStatusRepository.UpdateAsync(templateEntity);
|
||||
|
||||
return new UnifyResultDto("200", "修改成功", isTrue);
|
||||
}
|
||||
|
||||
private async Task<UnifyResultDto> DeleteAsync(EditTrackStatusInput input)
|
||||
{
|
||||
var isTrue = await _trackStatusRepository.SoftDeleteAsync(x => x.Id == input.Id);
|
||||
|
||||
return new UnifyResultDto("200", "删除成功", isTrue);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -1,10 +1,10 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using System.Linq.Expressions;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using SJZY.Expand.ABP.Core.Localization;
|
||||
using SJZY.Track.Application.Dtos.TrackTemplates;
|
||||
using SJZY.Track.Application.Localization;
|
||||
using SJZY.Track.Domain.TrackTemplateAggregate;
|
||||
using SJZY.Track.Domain.TrackTemplateAggregate.Dtos;
|
||||
using System.Linq.Expressions;
|
||||
using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
|
||||
using SJZY.Track.Domain.Dtos.TrackTemplate;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace SJZY.Track.Application.Services.TrackTemplates;
|
||||
@ -113,7 +113,8 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("GetContentPage")]
|
||||
public async Task<UnifyPageResultDto<GetTrackTemplateContentPageOutputVO>> GetContentPageAsync([FromBody] GetTrackTemplateContentPageInputVO input)
|
||||
public async Task<UnifyPageResultDto<GetTrackTemplateContentPageOutputVO>> GetContentPageAsync(
|
||||
[FromBody] GetTrackTemplateContentPageInputVO input)
|
||||
{
|
||||
return await _trackTemplateRepository.GetContentPageAsync(input);
|
||||
}
|
||||
@ -140,7 +141,7 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
|
||||
if (input.Options != OptionTypeNoNull.删除)
|
||||
{
|
||||
Expression<Func<TrackTemplateContentEntity, bool>> isAnyExp = x =>
|
||||
x.TrackTemplateId == input.TrackTemplateId && x.TrackContentId == input.TrackContentId;
|
||||
x.TrackTemplateId == input.TrackTemplateId && x.TrackContentId == input.TrackContentId;
|
||||
if (input.Options == OptionTypeNoNull.修改) isAnyExp.And(x => x.Id != input.Id);
|
||||
|
||||
if (await _trackTemplateRepository.IsAnyAsync(isAnyExp))
|
||||
@ -159,7 +160,8 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
|
||||
|
||||
case OptionTypeNoNull.修改:
|
||||
|
||||
var oldEntity = await _trackTemplateRepository.GetByIdAsync(input.Id!.Value) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
||||
var oldEntity = await _trackTemplateRepository.GetByIdAsync(input.Id!.Value) ??
|
||||
throw new BusinessException(message: _stringLocalizer["NotFindData"]);
|
||||
|
||||
ObjectMapper.Map(input, oldEntity);
|
||||
|
||||
@ -174,7 +176,8 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new BusinessException(message: _stringLocalizer[SjzyBasicLocalization.Validation_IsInEnum, nameof(EditTrackTemplateContentInput.Options)]);
|
||||
throw new BusinessException(message: _stringLocalizer[SjzyBasicLocalization.Validation_IsInEnum,
|
||||
nameof(EditTrackTemplateContentInput.Options)]);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
namespace SJZY.Track.Domain.DemoAggregate;
|
||||
namespace SJZY.Track.Domain.Aggregates.DemoAggregate;
|
||||
|
||||
[SugarTable("t_demo_detail")]
|
||||
public class DemoDetailEntity
|
||||
public class DemoDetailEntity : IEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Id
|
||||
@ -1,10 +1,10 @@
|
||||
namespace SJZY.Track.Domain.DemoAggregate;
|
||||
namespace SJZY.Track.Domain.Aggregates.DemoAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// 测试表
|
||||
/// </summary>
|
||||
[SugarTable("t_demo")]
|
||||
public class DemoEntity : IFullAuditedBasicEntitys
|
||||
public class DemoEntity : IFullAuditedBasicEntitys, IAggregateRoot
|
||||
{
|
||||
/// <summary>
|
||||
/// Id
|
||||
@ -33,5 +33,4 @@ public class DemoEntity : IFullAuditedBasicEntitys
|
||||
|
||||
[Navigate(NavigateType.OneToMany, nameof(DemoDetailEntity.DemoId))]
|
||||
public List<DemoDetailEntity> DemoDetailList { get; set; }
|
||||
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
using SJZY.Track.Domain.DemoAggregate.Dtos;
|
||||
using SJZY.Track.Domain.Dtos.Demo;
|
||||
|
||||
namespace SJZY.Track.Domain.DemoAggregate
|
||||
namespace SJZY.Track.Domain.Aggregates.DemoAggregate
|
||||
{
|
||||
public interface IDemoRepository
|
||||
{
|
||||
@ -1,6 +1,6 @@
|
||||
using SJZY.Track.Domain.OrderAggregate.Dtos;
|
||||
using SJZY.Track.Domain.Dtos.Order;
|
||||
|
||||
namespace SJZY.Track.Domain.OrderAggregate;
|
||||
namespace SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
|
||||
public interface IOrderRepository : IBasicRepository<OrderEntity>
|
||||
{
|
||||
@ -1,12 +1,13 @@
|
||||
namespace SJZY.Track.Domain.OrderAggregate;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹订单主表
|
||||
/// </summary>
|
||||
[SugarTable("t_order")]
|
||||
public class OrderEntity : IFullAuditedBasicEntitys
|
||||
public class OrderEntity : IFullAuditedBasicEntitys, IAggregateRoot
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 自增主键
|
||||
/// </summary>
|
||||
@ -67,4 +68,25 @@ public class OrderEntity : IFullAuditedBasicEntitys
|
||||
[SugarColumn(ColumnName = "SubSystemId")]
|
||||
public int SubSystemId { get; set; }
|
||||
|
||||
|
||||
public bool IsEqual(NoInfo noInfo)
|
||||
{
|
||||
return OrderType == noInfo.NoType && OrderNo == noInfo.OrderNo;
|
||||
}
|
||||
}
|
||||
|
||||
public struct NoInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单类型,必填
|
||||
/// </summary>
|
||||
[Required]
|
||||
public int NoType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号,必填
|
||||
/// </summary>
|
||||
[Required]
|
||||
[MaxLength(100)]
|
||||
public string OrderNo { get; set; }
|
||||
}
|
||||
@ -1,13 +1,12 @@
|
||||
namespace SJZY.Track.Domain.OrderAggregate;
|
||||
namespace SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹订单关联表(1:N)
|
||||
/// </summary>
|
||||
[SugarTable("t_order_link")]
|
||||
public class OrderLinkEntity : ICreateBaicEntity,
|
||||
ISoftDeleteBasicEntity
|
||||
ISoftDeleteBasicEntity, IEntity
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 自增主键
|
||||
/// </summary>
|
||||
@ -19,19 +18,19 @@ public class OrderLinkEntity : ICreateBaicEntity,
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "OrderType")]
|
||||
public int OrderType { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 订单号
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "OrderNo")]
|
||||
public string OrderNo { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 关联的订单类型
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "LinkOrderType")]
|
||||
public int LinkOrderType { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 关联的订单号
|
||||
/// </summary>
|
||||
@ -42,12 +41,12 @@ public class OrderLinkEntity : ICreateBaicEntity,
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
public int CreateUserId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? CreateTime { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 是否删除(已解绑)
|
||||
/// </summary>
|
||||
@ -1,12 +1,11 @@
|
||||
namespace SJZY.Track.Domain.OrderAggregate;
|
||||
namespace SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹订单模板表(1:N)
|
||||
/// </summary>
|
||||
[SugarTable("t_order_template")]
|
||||
public class OrderTemplateEntity : ICreateBaicEntity
|
||||
public class OrderTemplateEntity : ICreateBaicEntity, IEntity
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 自增主键
|
||||
/// </summary>
|
||||
@ -0,0 +1,5 @@
|
||||
namespace SJZY.Track.Domain.Aggregates.TrackContentAggregate;
|
||||
|
||||
public interface ITrackContentRepository : IBasicRepository<TrackContentEntity>
|
||||
{
|
||||
}
|
||||
@ -1,10 +1,10 @@
|
||||
namespace SJZY.Track.Domain.TrackContentAggregate;
|
||||
namespace SJZY.Track.Domain.Aggregates.TrackContentAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容
|
||||
/// </summary>
|
||||
[SugarTable("t_track_content")]
|
||||
public class TrackContentEntity : IFullAuditedBasicEntitys
|
||||
public class TrackContentEntity : IFullAuditedBasicEntitys, IAggregateRoot
|
||||
{
|
||||
/// <summary>
|
||||
/// 自增主键
|
||||
@ -1,10 +1,10 @@
|
||||
namespace SJZY.Track.Domain.TrackContentAggregate;
|
||||
namespace SJZY.Track.Domain.Aggregates.TrackContentAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容映射表
|
||||
/// </summary>
|
||||
[SugarTable("t_track_content_map")]
|
||||
public class TrackContentMapEntity : IFullAuditedBasicEntitys
|
||||
public class TrackContentMapEntity : IFullAuditedBasicEntitys, IEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 自增主键
|
||||
@ -1,7 +1,6 @@
|
||||
using SJZY.Track.Domain.TrackDetailsAggregate;
|
||||
using SJZY.Track.Repository.TrackDetails.Dtos;
|
||||
using SJZY.Track.Domain.Dtos.TrackDetails;
|
||||
|
||||
namespace SJZY.Track.Repository.TrackDetails;
|
||||
namespace SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||
|
||||
public interface ITrackDetailsRepository
|
||||
{
|
||||
@ -1,9 +1,9 @@
|
||||
using Nest;
|
||||
using SJZY.Expand.ElasticSearch;
|
||||
|
||||
namespace SJZY.Track.Domain.TrackDetailsAggregate;
|
||||
namespace SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||
|
||||
[ElasticsearchType(Name = IndexName)]
|
||||
[ElasticsearchType(RelationName = IndexName)]
|
||||
public class TrackDetailsIndex : IdBaseIndex
|
||||
{
|
||||
public const string IndexName = "sjzy_track_details";
|
||||
@ -1,4 +1,4 @@
|
||||
namespace SJZY.Track.Domain.TrackFlagAggregate;
|
||||
namespace SJZY.Track.Domain.Aggregates.TrackFlagAggregate;
|
||||
|
||||
public interface ITrackFlagRepository : IBasicRepository<TrackFlagEntity>
|
||||
{
|
||||
@ -1,10 +1,10 @@
|
||||
namespace SJZY.Track.Domain.TrackFlagAggregate;
|
||||
namespace SJZY.Track.Domain.Aggregates.TrackFlagAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹标记表
|
||||
/// </summary>
|
||||
[SugarTable("t_track_flag")]
|
||||
public class TrackFlagEntity : IFullAuditedBasicEntitys
|
||||
public class TrackFlagEntity : IFullAuditedBasicEntitys, IAggregateRoot
|
||||
{
|
||||
/// <summary>
|
||||
/// 自增主键
|
||||
@ -1,6 +1,5 @@
|
||||
namespace SJZY.Track.Domain.TrackPullAggregate;
|
||||
namespace SJZY.Track.Domain.Aggregates.TrackPullAggregate;
|
||||
|
||||
public interface ITrackPullConfigRepository : IBasicRepository<TrackPullConfigEntity>
|
||||
{
|
||||
|
||||
}
|
||||
@ -1,12 +1,11 @@
|
||||
namespace SJZY.Track.Domain.TrackPullAggregate;
|
||||
namespace SJZY.Track.Domain.Aggregates.TrackPullAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹拉取配置表
|
||||
/// </summary>
|
||||
[SugarTable("t_track_pull_config")]
|
||||
public class TrackPullConfigEntity : IFullAuditedBasicEntitys
|
||||
public class TrackPullConfigEntity : IFullAuditedBasicEntitys, IAggregateRoot
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 自增主键
|
||||
/// </summary>
|
||||
@ -42,5 +41,4 @@ public class TrackPullConfigEntity : IFullAuditedBasicEntitys
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "TrackTemplateId")]
|
||||
public int TrackTemplateId { get; set; }
|
||||
|
||||
}
|
||||
@ -1,12 +1,11 @@
|
||||
namespace SJZY.Track.Domain.TrackPullAggregate;
|
||||
namespace SJZY.Track.Domain.Aggregates.TrackPullAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹拉取内容配置表
|
||||
/// </summary>
|
||||
[SugarTable("t_track_pull_content_config")]
|
||||
public class TrackPullContentConfigEntity : IFullAuditedBasicEntitys
|
||||
public class TrackPullContentConfigEntity : IFullAuditedBasicEntitys, IEntity
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 自增主键
|
||||
/// </summary>
|
||||
@ -66,5 +65,4 @@ public class TrackPullContentConfigEntity : IFullAuditedBasicEntitys
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "TrackTimeZone")]
|
||||
public string TrackTimeZone { get; set; }
|
||||
|
||||
}
|
||||
@ -1,10 +1,10 @@
|
||||
namespace SJZY.Track.Domain.TrackPullAggregate;
|
||||
namespace SJZY.Track.Domain.Aggregates.TrackPullAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹拉取/推送参数配置
|
||||
/// </summary>
|
||||
[SugarTable("t_track_push_pull_params_config")]
|
||||
public class TrackPushPullParamsConfigEntity : IFullAuditedBasicEntitys
|
||||
public class TrackPushPullParamsConfigEntity : IFullAuditedBasicEntitys, IEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 自增主键
|
||||
@ -1,4 +1,4 @@
|
||||
namespace SJZY.Track.Domain.TrackPushAggregate;
|
||||
namespace SJZY.Track.Domain.Aggregates.TrackPushAggregate;
|
||||
|
||||
public interface ITrackPushConfigRepository : IBasicRepository<TrackPushConfigEntity>
|
||||
{
|
||||
@ -1,10 +1,10 @@
|
||||
namespace SJZY.Track.Domain.TrackPushAggregate;
|
||||
namespace SJZY.Track.Domain.Aggregates.TrackPushAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹推送配置表
|
||||
/// </summary>
|
||||
[SugarTable("t_track_push_config")]
|
||||
public class TrackPushConfigEntity : IFullAuditedBasicEntitys
|
||||
public class TrackPushConfigEntity : IFullAuditedBasicEntitys, IAggregateRoot
|
||||
{
|
||||
/// <summary>
|
||||
/// 自增主键
|
||||
@ -1,10 +1,10 @@
|
||||
namespace SJZY.Track.Domain.TrackPushAggregate;
|
||||
namespace SJZY.Track.Domain.Aggregates.TrackPushAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹推送内容配置表
|
||||
/// </summary>
|
||||
[SugarTable("t_track_push_content_config")]
|
||||
public class TrackPushContentConfigEntity : IFullAuditedBasicEntitys
|
||||
public class TrackPushContentConfigEntity : IFullAuditedBasicEntitys, IEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 自增主键
|
||||
@ -1,6 +1,5 @@
|
||||
namespace SJZY.Track.Domain.TrackStatusAggregate;
|
||||
namespace SJZY.Track.Domain.Aggregates.TrackStatusAggregate;
|
||||
|
||||
public interface ITrackStatusRepository : IBasicRepository<TrackStatusEntity>
|
||||
{
|
||||
|
||||
}
|
||||
@ -1,10 +1,10 @@
|
||||
namespace SJZY.Track.Domain.TrackStatusAggregate;
|
||||
namespace SJZY.Track.Domain.Aggregates.TrackStatusAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹状态表
|
||||
/// </summary>
|
||||
[SugarTable("t_track_status")]
|
||||
public class TrackStatusEntity : IFullAuditedBasicEntitys
|
||||
public class TrackStatusEntity : IFullAuditedBasicEntitys, IAggregateRoot
|
||||
{
|
||||
/// <summary>
|
||||
/// 自增主键
|
||||
@ -1,6 +1,6 @@
|
||||
using SJZY.Track.Domain.TrackTemplateAggregate.Dtos;
|
||||
using SJZY.Track.Domain.Dtos.TrackTemplate;
|
||||
|
||||
namespace SJZY.Track.Domain.TrackTemplateAggregate;
|
||||
namespace SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
|
||||
|
||||
public interface ITrackTemplateRepository : IBasicRepository<TrackTemplateEntity>
|
||||
{
|
||||
@ -15,7 +15,8 @@ public interface ITrackTemplateRepository : IBasicRepository<TrackTemplateEntity
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
Task<UnifyPageResultDto<GetTrackTemplateContentPageOutputVO>> GetContentPageAsync(GetTrackTemplateContentPageInputVO input);
|
||||
Task<UnifyPageResultDto<GetTrackTemplateContentPageOutputVO>> GetContentPageAsync(
|
||||
GetTrackTemplateContentPageInputVO input);
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹模板内容详情
|
||||
@ -1,10 +1,10 @@
|
||||
namespace SJZY.Track.Domain.TrackTemplateAggregate;
|
||||
namespace SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹模板内容表(1:N)
|
||||
/// </summary>
|
||||
[SugarTable("t_track_template_content")]
|
||||
public class TrackTemplateContentEntity : IFullAuditedBasicEntitys
|
||||
public class TrackTemplateContentEntity : IFullAuditedBasicEntitys, IEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 自增主键
|
||||
@ -1,12 +1,11 @@
|
||||
namespace SJZY.Track.Domain.TrackTemplateAggregate;
|
||||
namespace SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹模板表
|
||||
/// </summary>
|
||||
[SugarTable("t_track_template")]
|
||||
public class TrackTemplateEntity : IFullAuditedBasicEntitys
|
||||
public class TrackTemplateEntity : IFullAuditedBasicEntitys, IAggregateRoot
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 自增主键
|
||||
/// </summary>
|
||||
@ -30,5 +29,4 @@ public class TrackTemplateEntity : IFullAuditedBasicEntitys
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "SubSystemId")]
|
||||
public int SubSystemId { get; set; }
|
||||
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
namespace SJZY.Track.Domain.DemoAggregate.Dtos
|
||||
{
|
||||
public class DemoValueObject
|
||||
{
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前页码
|
||||
/// </summary>
|
||||
public int PageIndex { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 每页大小
|
||||
/// </summary>
|
||||
public int PageSize { get; set; }
|
||||
}
|
||||
}
|
||||
16
src/SJZY.Track.Domain/Dtos/Demo/DemoValueObject.cs
Normal file
16
src/SJZY.Track.Domain/Dtos/Demo/DemoValueObject.cs
Normal file
@ -0,0 +1,16 @@
|
||||
namespace SJZY.Track.Domain.Dtos.Demo;
|
||||
|
||||
public class DemoValueObject
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前页码
|
||||
/// </summary>
|
||||
public int PageIndex { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 每页大小
|
||||
/// </summary>
|
||||
public int PageSize { get; set; }
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
namespace SJZY.Track.Domain.OrderAggregate.Dtos;
|
||||
namespace SJZY.Track.Domain.Dtos.Order;
|
||||
|
||||
public class OrderTemplateDto
|
||||
{
|
||||
@ -1,4 +1,4 @@
|
||||
namespace SJZY.Track.Repository.TrackDetails.Dtos;
|
||||
namespace SJZY.Track.Domain.Dtos.TrackDetails;
|
||||
|
||||
public class TrackDetailsQueryInput : PageInfoInput
|
||||
{
|
||||
@ -1,4 +1,4 @@
|
||||
namespace SJZY.Track.Domain.TrackTemplateAggregate.Dtos;
|
||||
namespace SJZY.Track.Domain.Dtos.TrackTemplate;
|
||||
|
||||
public class GetPageTrackTemplateVO : PageInfoInput
|
||||
{
|
||||
@ -0,0 +1,41 @@
|
||||
namespace SJZY.Track.Domain.Dtos.TrackTemplate;
|
||||
|
||||
public class GetTrackTemplateContentDetailOutputVO
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否可删
|
||||
/// </summary>
|
||||
public bool IsCanDelete { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否对外
|
||||
/// </summary>
|
||||
public bool IsExternal { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
public int Sort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容
|
||||
/// </summary>
|
||||
public string TrackContent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容id
|
||||
/// </summary>
|
||||
public int TrackContentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹状态
|
||||
/// </summary>
|
||||
public string TrackStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹状态id
|
||||
/// </summary>
|
||||
public int TrackStatusId { get; set; }
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
namespace SJZY.Track.Domain.TrackTemplateAggregate.Dtos;
|
||||
namespace SJZY.Track.Domain.Dtos.TrackTemplate;
|
||||
|
||||
public class GetTrackTemplateContentPageInputVO : PageInfoInput
|
||||
{
|
||||
@ -1,4 +1,4 @@
|
||||
namespace SJZY.Track.Domain.TrackTemplateAggregate.Dtos;
|
||||
namespace SJZY.Track.Domain.Dtos.TrackTemplate;
|
||||
|
||||
public class GetTrackTemplateContentPageOutputVO
|
||||
{
|
||||
@ -1,4 +1,4 @@
|
||||
namespace SJZY.Track.Domain.TrackTemplateAggregate.Dtos;
|
||||
namespace SJZY.Track.Domain.Dtos.TrackTemplate;
|
||||
|
||||
/// <summary>
|
||||
/// 获取轨迹模版明细
|
||||
@ -0,0 +1,5 @@
|
||||
namespace SJZY.Track.Domain.Dtos.TrackTemplate;
|
||||
|
||||
public class TemplateContentDto
|
||||
{
|
||||
}
|
||||
@ -7,3 +7,4 @@ global using System;
|
||||
global using System.Collections.Generic;
|
||||
global using System.Linq.Expressions;
|
||||
global using System.Threading.Tasks;
|
||||
global using SJZY.Track.Domain.SeedWork;
|
||||
38
src/SJZY.Track.Domain/IBasicQuery.cs
Normal file
38
src/SJZY.Track.Domain/IBasicQuery.cs
Normal file
@ -0,0 +1,38 @@
|
||||
namespace SJZY.Track.Domain;
|
||||
|
||||
public interface IBasicQuery<T> where T : IEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// top 1
|
||||
/// </summary>
|
||||
/// <param name="whereExpression"></param>
|
||||
/// <returns></returns>
|
||||
Task<T> GetFirstAsync(Expression<Func<T, bool>> whereExpression);
|
||||
|
||||
Task<TResult> GetFirstAsync<TResult>(Expression<Func<T, bool>> whereExpression,
|
||||
Expression<Func<T, TResult>> resultExpression);
|
||||
|
||||
/// <summary>
|
||||
/// get list
|
||||
/// </summary>
|
||||
/// <param name="whereExpression"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<T>> GetListAsync(Expression<Func<T, bool>> whereExpression);
|
||||
|
||||
Task<List<TResult>> GetListAsync<TResult>(Expression<Func<T, bool>> whereExpression,
|
||||
Expression<Func<T, TResult>> resultExpression);
|
||||
|
||||
/// <summary>
|
||||
/// count
|
||||
/// </summary>
|
||||
/// <param name="exp"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> CountAsync(Expression<Func<T, bool>> exp);
|
||||
|
||||
/// <summary>
|
||||
/// exists
|
||||
/// </summary>
|
||||
/// <param name="exp"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> IsAnyAsync(Expression<Func<T, bool>> exp);
|
||||
}
|
||||
@ -1,39 +1,7 @@
|
||||
namespace SJZY.Track.Domain;
|
||||
|
||||
public interface IBasicRepository<T>
|
||||
public interface IBasicRepository<T> : IBasicQuery<T> where T : IAggregateRoot
|
||||
{
|
||||
/// <summary>
|
||||
/// top 1
|
||||
/// </summary>
|
||||
/// <param name="whereExpression"></param>
|
||||
/// <returns></returns>
|
||||
Task<T> GetFirstAsync(Expression<Func<T, bool>> whereExpression);
|
||||
|
||||
Task<TResult> GetFirstAsync<TResult>(Expression<Func<T, bool>> whereExpression, Expression<Func<T, TResult>> resultExpression);
|
||||
|
||||
/// <summary>
|
||||
/// get list
|
||||
/// </summary>
|
||||
/// <param name="whereExpression"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<T>> GetListAsync(Expression<Func<T, bool>> whereExpression);
|
||||
|
||||
Task<List<TResult>> GetListAsync<TResult>(Expression<Func<T, bool>> whereExpression, Expression<Func<T, TResult>> resultExpression);
|
||||
|
||||
/// <summary>
|
||||
/// count
|
||||
/// </summary>
|
||||
/// <param name="exp"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> CountAsync(Expression<Func<T, bool>> exp);
|
||||
|
||||
/// <summary>
|
||||
/// exists
|
||||
/// </summary>
|
||||
/// <param name="exp"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> IsAnyAsync(Expression<Func<T, bool>> exp);
|
||||
|
||||
/// <summary>
|
||||
/// update
|
||||
/// </summary>
|
||||
|
||||
@ -12,12 +12,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="TrackContentAggregate\Dtos\" />
|
||||
<Folder Include="TrackFlagAggregate\Dtos\" />
|
||||
<Folder Include="TrackPullAggregate\Dtos\" />
|
||||
<Folder Include="TrackPushAggregate\Dtos\" />
|
||||
<Folder Include="TrackStatusAggregate\Dtos\" />
|
||||
<Folder Include="TrackStatusAggregate\Dtos\" />
|
||||
<Folder Include="Aggregates\"/>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
5
src/SJZY.Track.Domain/SeedWork/IAggregateRoot.cs
Normal file
5
src/SJZY.Track.Domain/SeedWork/IAggregateRoot.cs
Normal file
@ -0,0 +1,5 @@
|
||||
namespace SJZY.Track.Domain.SeedWork;
|
||||
|
||||
public interface IAggregateRoot : IEntity
|
||||
{
|
||||
}
|
||||
5
src/SJZY.Track.Domain/SeedWork/IEntity.cs
Normal file
5
src/SJZY.Track.Domain/SeedWork/IEntity.cs
Normal file
@ -0,0 +1,5 @@
|
||||
namespace SJZY.Track.Domain.SeedWork;
|
||||
|
||||
public interface IEntity
|
||||
{
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
namespace SJZY.Track.Domain.TrackContentAggregate
|
||||
{
|
||||
public interface ITrackContentRepository : IBasicRepository<TrackContentEntity>
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -1,42 +0,0 @@
|
||||
namespace SJZY.Track.Domain.TrackTemplateAggregate.Dtos
|
||||
{
|
||||
public class GetTrackTemplateContentDetailOutputVO
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否可删
|
||||
/// </summary>
|
||||
public bool IsCanDelete { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否对外
|
||||
/// </summary>
|
||||
public bool IsExternal { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
public int Sort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容
|
||||
/// </summary>
|
||||
public string TrackContent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容id
|
||||
/// </summary>
|
||||
public int TrackContentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹状态
|
||||
/// </summary>
|
||||
public string TrackStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹状态id
|
||||
/// </summary>
|
||||
public int TrackStatusId { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
namespace SJZY.Track.Domain.TrackTemplateAggregate.Dtos;
|
||||
|
||||
public class TemplateContentDto
|
||||
{
|
||||
|
||||
}
|
||||
25
src/SJZY.Track.Repository/BasicQuery.cs
Normal file
25
src/SJZY.Track.Repository/BasicQuery.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System.Linq.Expressions;
|
||||
using SJZY.Track.Domain;
|
||||
using SJZY.Track.Domain.SeedWork;
|
||||
|
||||
namespace SJZY.Track.Repository;
|
||||
|
||||
public class BasicQuery<T> : SimpleClient<T>, IBasicQuery<T> where T : class, IEntity, new()
|
||||
{
|
||||
public BasicQuery()
|
||||
{
|
||||
Context = SqlsugarScopeBasic.GetContextSafely("default");
|
||||
}
|
||||
|
||||
public async Task<TResult> GetFirstAsync<TResult>(Expression<Func<T, bool>> whereExpression,
|
||||
Expression<Func<T, TResult>> resultExpression)
|
||||
{
|
||||
return await Context.Queryable<T>().Where(whereExpression).Select(resultExpression).FirstAsync();
|
||||
}
|
||||
|
||||
public async Task<List<TResult>> GetListAsync<TResult>(Expression<Func<T, bool>> whereExpression,
|
||||
Expression<Func<T, TResult>> resultExpression)
|
||||
{
|
||||
return await Context.Queryable<T>().Where(whereExpression).Select(resultExpression).ToListAsync();
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
using SJZY.Track.Domain;
|
||||
using System.Linq.Expressions;
|
||||
using System.Linq.Expressions;
|
||||
using SJZY.Track.Domain;
|
||||
using SJZY.Track.Domain.SeedWork;
|
||||
using Volo.Abp;
|
||||
|
||||
namespace SJZY.Track.Repository;
|
||||
@ -8,25 +9,8 @@ namespace SJZY.Track.Repository;
|
||||
/// 仓储基类实现
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class BasicRepository<T> : SimpleClient<T>, IBasicRepository<T> where T : class, new()
|
||||
public class BasicRepository<T> : BasicQuery<T>, IBasicRepository<T> where T : class, IAggregateRoot, new()
|
||||
{
|
||||
public BasicRepository()
|
||||
{
|
||||
Context = SqlsugarScopeBasic.GetContextSafely("default");
|
||||
}
|
||||
|
||||
public async Task<TResult> GetFirstAsync<TResult>(Expression<Func<T, bool>> whereExpression,
|
||||
Expression<Func<T, TResult>> resultExpression)
|
||||
{
|
||||
return await Context.Queryable<T>().Where(whereExpression).Select(resultExpression).FirstAsync();
|
||||
}
|
||||
|
||||
public async Task<List<TResult>> GetListAsync<TResult>(Expression<Func<T, bool>> whereExpression,
|
||||
Expression<Func<T, TResult>> resultExpression)
|
||||
{
|
||||
return await Context.Queryable<T>().Where(whereExpression).Select(resultExpression).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<bool> UpdateAsync(T entity, Expression<Func<T, object>> ignoreColumns)
|
||||
{
|
||||
return await Context.Updateable(entity)
|
||||
|
||||
@ -1,84 +1,87 @@
|
||||
using SJZY.Track.Domain.DemoAggregate;
|
||||
using SJZY.Track.Domain.DemoAggregate.Dtos;
|
||||
using System.Transactions;
|
||||
using System.Transactions;
|
||||
using SJZY.Track.Domain.Aggregates.DemoAggregate;
|
||||
using SJZY.Track.Domain.Dtos.Demo;
|
||||
|
||||
namespace SJZY.Track.Repository
|
||||
namespace SJZY.Track.Repository;
|
||||
|
||||
public class DemoRepository : BasicRepository<DemoEntity>, IDemoRepository, IScopedDependency
|
||||
{
|
||||
public class DemoRepository : BasicRepository<DemoEntity>, IDemoRepository, IScopedDependency
|
||||
/*
|
||||
一般情况下常规的增删改方法不需要自己实现,只需要按照 BasicRepository 中的格式原封不动的暴露出去即可,
|
||||
比如这里接口 只声明了 UpdateAsync 和 InsertReturnIdentityAsync 接口的定义,但是这两个方法的实现我们不用写,直接交给父类实现即可
|
||||
*/
|
||||
|
||||
#region 根据主键获取单条数据
|
||||
|
||||
/// <summary>
|
||||
/// 根据主键获取单条数据
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public Task<DemoEntity> GetById1(int id)
|
||||
{
|
||||
/*
|
||||
一般情况下常规的增删改方法不需要自己实现,只需要按照 BasicRepository 中的格式原封不动的暴露出去即可,
|
||||
比如这里接口 只声明了 UpdateAsync 和 InsertReturnIdentityAsync 接口的定义,但是这两个方法的实现我们不用写,直接交给父类实现即可
|
||||
|
||||
//以下两种方法都不会因为没找到数据而抛异常
|
||||
var model1 = base.GetFirst(m => m.Id == 0);
|
||||
var model = base.GetSingle(m => m.Id == 0);
|
||||
|
||||
|
||||
|
||||
//同样的写法在linq下,如果不加 OrDefault 一定会报错
|
||||
var model = base.GetList().Single(m => m.Id == 0);
|
||||
var model1 = base.GetList().First(m => m.Id == 0);
|
||||
|
||||
*/
|
||||
return base.GetSingleAsync(it => it.Id == id);
|
||||
}
|
||||
|
||||
#region 根据主键获取单条数据
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 根据主键获取单条数据
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public Task<DemoEntity> GetById1(int id)
|
||||
{
|
||||
/*
|
||||
|
||||
//以下两种方法都不会因为没找到数据而抛异常
|
||||
var model1 = base.GetFirst(m => m.Id == 0);
|
||||
var model = base.GetSingle(m => m.Id == 0);
|
||||
|
||||
#region 分页获取
|
||||
|
||||
/// <summary>
|
||||
/// 分页获取
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<UnifyPageResultDto<DemoEntity>> GetListByPage(int pageSize, int pageindex, string name)
|
||||
{
|
||||
var list = await AsQueryable()
|
||||
.WhereIF(!string.IsNullOrEmpty(name), a => a.Name.Contains(name))
|
||||
.ToPagedListAsync(pageindex, pageSize);
|
||||
|
||||
//同样的写法在linq下,如果不加 OrDefault 一定会报错
|
||||
var model = base.GetList().Single(m => m.Id == 0);
|
||||
var model1 = base.GetList().First(m => m.Id == 0);
|
||||
return list;
|
||||
}
|
||||
|
||||
*/
|
||||
return base.GetSingleAsync(it => it.Id == id);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#region 参数为实体
|
||||
|
||||
#region 分页获取
|
||||
/// <summary>
|
||||
/// 参数很多的时候,定义模型接受参数
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<DemoEntity>> InputToValueObject(DemoValueObject obj)
|
||||
{
|
||||
var list = await AsQueryable().ToListAsync();
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页获取
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<UnifyPageResultDto<DemoEntity>> GetListByPage(int pageSize, int pageindex, string name)
|
||||
{
|
||||
var list = await AsQueryable()
|
||||
.WhereIF(!string.IsNullOrEmpty(name), a => a.Name.Contains(name))
|
||||
.ToPagedListAsync(pageindex, pageSize);
|
||||
#endregion
|
||||
|
||||
return list;
|
||||
}
|
||||
#endregion
|
||||
#region 执行原生sql语句
|
||||
|
||||
#region 参数为实体
|
||||
|
||||
/// <summary>
|
||||
/// 参数很多的时候,定义模型接受参数
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<DemoEntity>> InputToValueObject(DemoValueObject obj)
|
||||
{
|
||||
var list = await AsQueryable().ToListAsync();
|
||||
return list;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 执行原生sql语句
|
||||
/// <summary>
|
||||
/// 执行原生sql语句
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<UnifyPageResultDto<DemoValueObject>> OriginalSql(DemoValueObject obj)
|
||||
{
|
||||
var parameters = new List<SugarParameter>();
|
||||
var sql = @$"
|
||||
/// <summary>
|
||||
/// 执行原生sql语句
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<UnifyPageResultDto<DemoValueObject>> OriginalSql(DemoValueObject obj)
|
||||
{
|
||||
var parameters = new List<SugarParameter>();
|
||||
var sql = @$"
|
||||
select
|
||||
a.id,
|
||||
a.Name,
|
||||
@ -89,110 +92,117 @@ namespace SJZY.Track.Repository
|
||||
{" and a.Name like @Name ".WhereIF(!string.IsNullOrEmpty(obj.Name), obj.Name, ref parameters)}
|
||||
order by a.id desc ";
|
||||
|
||||
var list = await Context.SqlQueryable<DemoValueObject>(sql)
|
||||
.AddParameters(parameters)
|
||||
.ToPagedListAsync(obj.PageIndex, obj.PageSize);
|
||||
var list = await Context.SqlQueryable<DemoValueObject>(sql)
|
||||
.AddParameters(parameters)
|
||||
.ToPagedListAsync(obj.PageIndex, obj.PageSize);
|
||||
|
||||
return list;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region 简单事务
|
||||
public async Task Transaction()
|
||||
#region 简单事务
|
||||
|
||||
public async Task Transaction()
|
||||
{
|
||||
using (var ts = new TransactionScope())
|
||||
{
|
||||
await base.InsertAsync(new DemoEntity { Name = "1111" });
|
||||
await base.InsertAsync(new DemoEntity { Name = "222" });
|
||||
await base.InsertAsync(new DemoEntity { Name = "3333" });
|
||||
|
||||
using (var ts = new TransactionScope())
|
||||
{
|
||||
//throw new BusinessException("E05632","手动抛异常");
|
||||
await base.InsertAsync(new DemoEntity { Name = "4444" });
|
||||
|
||||
await base.InsertAsync(new DemoEntity { Name = "1111" });
|
||||
await base.InsertAsync(new DemoEntity { Name = "222" });
|
||||
await base.InsertAsync(new DemoEntity { Name = "3333" });
|
||||
|
||||
//throw new BusinessException("E05632","手动抛异常");
|
||||
await base.InsertAsync(new DemoEntity { Name = "4444" });
|
||||
|
||||
ts.Complete();
|
||||
}
|
||||
ts.Complete();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region 夸方法事务
|
||||
public async Task MultipleMethodTrans1()
|
||||
#endregion
|
||||
|
||||
#region 夸方法事务
|
||||
|
||||
public async Task MultipleMethodTrans1()
|
||||
{
|
||||
await base.InsertAsync(new DemoEntity { Name = "---" });
|
||||
await base.InsertAsync(new DemoEntity { Name = "+++" });
|
||||
}
|
||||
|
||||
public async Task MultipleMethodTrans2()
|
||||
{
|
||||
//throw new BusinessException(message: "手动抛出异常");
|
||||
await base.InsertAsync(new DemoEntity { Name = "xxx" });
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 事务嵌套
|
||||
|
||||
public async Task InternalTrans()
|
||||
{
|
||||
using (var ts = new TransactionScope())
|
||||
{
|
||||
await base.InsertAsync(new DemoEntity { Name = "---" });
|
||||
await base.InsertAsync(new DemoEntity { Name = "+++" });
|
||||
}
|
||||
|
||||
public async Task MultipleMethodTrans2()
|
||||
{
|
||||
|
||||
await Transaction();
|
||||
await MultipleMethodTrans1();
|
||||
//throw new BusinessException(message: "手动抛出异常");
|
||||
await base.InsertAsync(new DemoEntity { Name = "xxx" });
|
||||
|
||||
ts.Complete();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 事务嵌套
|
||||
public async Task InternalTrans()
|
||||
{
|
||||
using (var ts = new TransactionScope())
|
||||
{
|
||||
await Transaction();
|
||||
await MultipleMethodTrans1();
|
||||
//throw new BusinessException(message: "手动抛出异常");
|
||||
await base.InsertAsync(new DemoEntity { Name = "xxx" });
|
||||
|
||||
ts.Complete();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 局部更新
|
||||
public async Task UpdatePartColumns(DemoEntity entity)
|
||||
{
|
||||
Context.Updateable(entity).UpdateColumns(m => new { m.Description, m.Name }).ExecuteCommand();
|
||||
// UPDATE `test` SET `Name`= 'string',`Description`= 'string' WHERE `id`= 5
|
||||
|
||||
Context.Updateable(entity).IgnoreColumns(m => new { m.CreateUserId, m.Age }).ExecuteCommand();
|
||||
// UPDATE `test` SET`IsDeleted`= 0,`Name`= 'string',`Description`= 'string',`EnabledMark`= 0,`DeleteUserId`= 0,`DeleteTime`= '2022/8/13 23:42:36',`CreateTime`= '2015/5/12 0:00:00',`UpdateUserId`= 0,`UpdateTime`= '2022/8/13 23:55:27' WHERE `id`= 5
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 导航属性
|
||||
/// <summary>
|
||||
/// 导航属性
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public async Task<bool> EntityRelationSave(DemoEntity entity)
|
||||
{
|
||||
var res = await Context.InsertNav(entity).Include(m => m.DemoDetailList).ExecuteCommandAsync();
|
||||
return res;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 缓存
|
||||
/// <summary>
|
||||
/// 获取数据包含缓存
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<DemoEntity> GetDataCache(int id)
|
||||
{
|
||||
var redisKey = $"Demo:Endity:{id}";
|
||||
var demo = await RedisHelper.Client.GetAsync<DemoEntity>(redisKey);
|
||||
if (demo != null)
|
||||
return demo;
|
||||
|
||||
var aa = Context.Ado.Connection;
|
||||
demo = await base.GetSingleAsync(m => m.Id == id);
|
||||
|
||||
await RedisHelper.Client.SetAsync(redisKey, demo, 60 * 20);
|
||||
|
||||
return demo;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 局部更新
|
||||
|
||||
public async Task UpdatePartColumns(DemoEntity entity)
|
||||
{
|
||||
Context.Updateable(entity).UpdateColumns(m => new { m.Description, m.Name }).ExecuteCommand();
|
||||
// UPDATE `test` SET `Name`= 'string',`Description`= 'string' WHERE `id`= 5
|
||||
|
||||
Context.Updateable(entity).IgnoreColumns(m => new { m.CreateUserId, m.Age }).ExecuteCommand();
|
||||
// UPDATE `test` SET`IsDeleted`= 0,`Name`= 'string',`Description`= 'string',`EnabledMark`= 0,`DeleteUserId`= 0,`DeleteTime`= '2022/8/13 23:42:36',`CreateTime`= '2015/5/12 0:00:00',`UpdateUserId`= 0,`UpdateTime`= '2022/8/13 23:55:27' WHERE `id`= 5
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 导航属性
|
||||
|
||||
/// <summary>
|
||||
/// 导航属性
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public async Task<bool> EntityRelationSave(DemoEntity entity)
|
||||
{
|
||||
var res = await Context.InsertNav(entity).Include(m => m.DemoDetailList).ExecuteCommandAsync();
|
||||
return res;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 缓存
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据包含缓存
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<DemoEntity> GetDataCache(int id)
|
||||
{
|
||||
var redisKey = $"Demo:Endity:{id}";
|
||||
var demo = await RedisHelper.Client.GetAsync<DemoEntity>(redisKey);
|
||||
if (demo != null)
|
||||
return demo;
|
||||
|
||||
var aa = Context.Ado.Connection;
|
||||
demo = await base.GetSingleAsync(m => m.Id == id);
|
||||
|
||||
await RedisHelper.Client.SetAsync(redisKey, demo, 60 * 20);
|
||||
|
||||
return demo;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
using SJZY.Track.Domain.OrderAggregate;
|
||||
using SJZY.Track.Domain.OrderAggregate.Dtos;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Dtos.Order;
|
||||
|
||||
namespace SJZY.Track.Repository;
|
||||
|
||||
|
||||
@ -21,7 +21,8 @@ public class SJZYTrackRepositoryModule : AbpModule
|
||||
|
||||
context.Services.AddSqlsugar(options =>
|
||||
{
|
||||
options.AddRange(new List<SqlsugarOptions> {
|
||||
options.AddRange(new List<SqlsugarOptions>
|
||||
{
|
||||
new()
|
||||
{
|
||||
ConnectionString = configuration["ConnectionStrings:DefaultConnection"],
|
||||
@ -33,10 +34,6 @@ public class SJZYTrackRepositoryModule : AbpModule
|
||||
);
|
||||
}, DataBaseContext.OnExcutingAction, "SJZY.Track.Repository");
|
||||
|
||||
|
||||
context.Services.AddScoped(typeof(IBasicRepository<>), typeof(BasicRepository<>));
|
||||
|
||||
|
||||
context.Services.AddElasticSearch(options =>
|
||||
{
|
||||
options.NodeUrls = configuration.GetSection("ElasticSearch:NodeUrls").Get<List<string>>();
|
||||
@ -45,4 +42,10 @@ public class SJZYTrackRepositoryModule : AbpModule
|
||||
options.Base64PassPassword = configuration["ElasticSearch:Base64PassPassword"];
|
||||
});
|
||||
}
|
||||
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
context.Services.AddTransient(typeof(IBasicQuery<>), typeof(BasicQuery<>));
|
||||
context.Services.AddTransient(typeof(IBasicRepository<>), typeof(BasicRepository<>));
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
using SJZY.Track.Domain.TrackContentAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackContentAggregate;
|
||||
|
||||
namespace SJZY.Track.Repository;
|
||||
|
||||
|
||||
@ -2,9 +2,8 @@ using Nest;
|
||||
using SJZY.Expand.ABP.Core.Logger;
|
||||
using SJZY.Expand.ABP.Core.PublicMethords;
|
||||
using SJZY.Expand.ElasticSearch.Services;
|
||||
using SJZY.Track.Domain.TrackDetailsAggregate;
|
||||
using SJZY.Track.Repository.TrackDetails;
|
||||
using SJZY.Track.Repository.TrackDetails.Dtos;
|
||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||
using SJZY.Track.Domain.Dtos.TrackDetails;
|
||||
|
||||
namespace SJZY.Track.Repository;
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using SJZY.Track.Domain.TrackFlagAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackFlagAggregate;
|
||||
|
||||
namespace SJZY.Track.Repository;
|
||||
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
using SJZY.Track.Domain.TrackPullAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
|
||||
|
||||
namespace SJZY.Track.Repository;
|
||||
|
||||
public class TrackPullConfigRepository : BasicRepository<TrackPullConfigEntity>, ITrackPullConfigRepository, IScopedDependency
|
||||
public class TrackPullConfigRepository : BasicRepository<TrackPullConfigEntity>, ITrackPullConfigRepository,
|
||||
IScopedDependency
|
||||
{
|
||||
}
|
||||
@ -1,7 +1,8 @@
|
||||
using SJZY.Track.Domain.TrackPushAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
|
||||
|
||||
namespace SJZY.Track.Repository;
|
||||
|
||||
public class TrackPushConfigRepository : BasicRepository<TrackPushConfigEntity>, ITrackPushConfigRepository, IScopedDependency
|
||||
public class TrackPushConfigRepository : BasicRepository<TrackPushConfigEntity>, ITrackPushConfigRepository,
|
||||
IScopedDependency
|
||||
{
|
||||
}
|
||||
@ -1,12 +1,13 @@
|
||||
namespace SJZY.Track.Repository.TrackPushRecord.Entitys
|
||||
using SJZY.Track.Domain.SeedWork;
|
||||
|
||||
namespace SJZY.Track.Repository.TrackPushRecord.Entitys
|
||||
{
|
||||
/// <summary>
|
||||
/// 轨迹推送记录
|
||||
/// </summary>
|
||||
[SugarTable("t_track_push_record")]
|
||||
public class TrackPushRecordEntity
|
||||
public class TrackPushRecordEntity : IAggregateRoot
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 自增主键
|
||||
/// </summary>
|
||||
@ -54,6 +55,5 @@
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "TrackTotal")]
|
||||
public string TrackTotal { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,12 +1,13 @@
|
||||
namespace SJZY.Track.Repository.TrackPushRecordDetails.Entitys
|
||||
using SJZY.Track.Domain.SeedWork;
|
||||
|
||||
namespace SJZY.Track.Repository.TrackPushRecordDetails.Entitys
|
||||
{
|
||||
/// <summary>
|
||||
/// 轨迹推送明细表
|
||||
/// </summary>
|
||||
[SugarTable("t_track_push_record_details")]
|
||||
public class TrackPushRecordDetailsEntity
|
||||
public class TrackPushRecordDetailsEntity : IAggregateRoot
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 自增主键
|
||||
/// </summary>
|
||||
@ -42,6 +43,5 @@
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "PushRecordId")]
|
||||
public int PushRecordId { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
using SJZY.Track.Domain.TrackStatusAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackStatusAggregate;
|
||||
|
||||
namespace SJZY.Track.Repository;
|
||||
|
||||
@ -7,6 +7,4 @@ public class TrackStatusRepository : BasicRepository<TrackStatusEntity>, ITrackS
|
||||
public TrackStatusRepository()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,13 +1,12 @@
|
||||
using SJZY.Expand.ABP.Core.Common.Dto;
|
||||
using System.Linq.Expressions;
|
||||
using SJZY.Expand.ABP.Core.PublicMethords;
|
||||
using SJZY.Track.Domain.TrackContentAggregate;
|
||||
using SJZY.Track.Domain.TrackFlagAggregate;
|
||||
using SJZY.Track.Domain.TrackStatusAggregate;
|
||||
using SJZY.Track.Domain.TrackTemplateAggregate;
|
||||
using SJZY.Track.Domain.TrackTemplateAggregate.Dtos;
|
||||
using SJZY.Track.Domain.Aggregates.TrackContentAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackFlagAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackStatusAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
|
||||
using SJZY.Track.Domain.Dtos.TrackTemplate;
|
||||
using SJZY.Track.Domain.VEntities;
|
||||
using SJZY.Track.Repository.Enum;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace SJZY.Track.Repository;
|
||||
|
||||
@ -26,17 +25,18 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
|
||||
/// <returns></returns>
|
||||
public async Task<GetTrackTemplateDetailVO?> GetDetailAsync(int id)
|
||||
{
|
||||
var detail = await Context.Queryable<TrackTemplateEntity>().LeftJoin<VSystemEntity>((a, b) => a.SubSystemId == b.Id)
|
||||
var detail = await Context.Queryable<TrackTemplateEntity>()
|
||||
.LeftJoin<VSystemEntity>((a, b) => a.SubSystemId == b.Id)
|
||||
.Where((a, b) => a.Id == id)
|
||||
.Select((a, b) => new
|
||||
GetTrackTemplateDetailVO
|
||||
{
|
||||
Id = a.Id,
|
||||
Code = a.Code,
|
||||
Name = a.Name,
|
||||
SubSystemId = a.SubSystemId,
|
||||
SubSystem = b.CnName
|
||||
}).FirstAsync();
|
||||
{
|
||||
Id = a.Id,
|
||||
Code = a.Code,
|
||||
Name = a.Name,
|
||||
SubSystemId = a.SubSystemId,
|
||||
SubSystem = b.CnName
|
||||
}).FirstAsync();
|
||||
|
||||
return detail;
|
||||
}
|
||||
@ -49,44 +49,47 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
|
||||
public async Task<UnifyPageResultDto<GetTrackTemplateListVO>> GetPageTrackTemplate(GetPageTrackTemplateVO input)
|
||||
{
|
||||
UnifyPageResultDto<GetTrackTemplateListVO> pagedList = new UnifyPageResultDto<GetTrackTemplateListVO>();
|
||||
pagedList = await Context.Queryable<TrackTemplateEntity>().LeftJoin<VSystemEntity>((a, b) => a.SubSystemId == b.Id)
|
||||
.WhereIF(input.SubSystemId > 0, (a, b) => a.SubSystemId == input.SubSystemId)
|
||||
.WhereIF(!input.Keywords.IsNullOrWhiteSpace(), (a, b) => a.Name.Contains(input.Keywords) || a.Code.Contains(input.Keywords))
|
||||
.Select((a, b) => new GetTrackTemplateListVO
|
||||
{
|
||||
Id = a.Id,
|
||||
Code = a.Code,
|
||||
CreateTime = a.CreateTime,
|
||||
Name = a.Name,
|
||||
SubSystem = b.CnName
|
||||
})
|
||||
.ToPagedListAsync(input.PageIndex, input.PageSize);
|
||||
//如果轨迹模版id传值了,就置顶在第一条
|
||||
if (input.TrackTemplateId>0&& (!pagedList.List.IsNullOrEmpty()))
|
||||
{
|
||||
if (input.PageIndex==1)
|
||||
pagedList = await Context.Queryable<TrackTemplateEntity>()
|
||||
.LeftJoin<VSystemEntity>((a, b) => a.SubSystemId == b.Id)
|
||||
.WhereIF(input.SubSystemId > 0, (a, b) => a.SubSystemId == input.SubSystemId)
|
||||
.WhereIF(!input.Keywords.IsNullOrWhiteSpace(),
|
||||
(a, b) => a.Name.Contains(input.Keywords) || a.Code.Contains(input.Keywords))
|
||||
.Select((a, b) => new GetTrackTemplateListVO
|
||||
{
|
||||
bool existCurrent = pagedList.List.Any(x => x.Id==input.TrackTemplateId);
|
||||
Id = a.Id,
|
||||
Code = a.Code,
|
||||
CreateTime = a.CreateTime,
|
||||
Name = a.Name,
|
||||
SubSystem = b.CnName
|
||||
})
|
||||
.ToPagedListAsync(input.PageIndex, input.PageSize);
|
||||
//如果轨迹模版id传值了,就置顶在第一条
|
||||
if (input.TrackTemplateId > 0 && (!pagedList.List.IsNullOrEmpty()))
|
||||
{
|
||||
if (input.PageIndex == 1)
|
||||
{
|
||||
bool existCurrent = pagedList.List.Any(x => x.Id == input.TrackTemplateId);
|
||||
if (existCurrent)
|
||||
{
|
||||
var item = pagedList.List.FirstOrDefault(x => x.Id==input.TrackTemplateId);
|
||||
var item = pagedList.List.FirstOrDefault(x => x.Id == input.TrackTemplateId);
|
||||
pagedList.List.Remove(item);
|
||||
pagedList.List.Insert(0, item);
|
||||
}
|
||||
else
|
||||
{
|
||||
var item = await Context.Queryable<TrackTemplateEntity>().LeftJoin<VSystemEntity>((a, b) => a.SubSystemId == b.Id)
|
||||
.Where((a, b) => a.Id==input.TrackTemplateId)
|
||||
.Select((a, b) => new GetTrackTemplateListVO
|
||||
{
|
||||
Id = a.Id,
|
||||
Code = a.Code,
|
||||
CreateTime = a.CreateTime,
|
||||
Name = a.Name,
|
||||
SubSystem = b.CnName
|
||||
})
|
||||
.FirstAsync();
|
||||
if (item!=null)
|
||||
var item = await Context.Queryable<TrackTemplateEntity>()
|
||||
.LeftJoin<VSystemEntity>((a, b) => a.SubSystemId == b.Id)
|
||||
.Where((a, b) => a.Id == input.TrackTemplateId)
|
||||
.Select((a, b) => new GetTrackTemplateListVO
|
||||
{
|
||||
Id = a.Id,
|
||||
Code = a.Code,
|
||||
CreateTime = a.CreateTime,
|
||||
Name = a.Name,
|
||||
SubSystem = b.CnName
|
||||
})
|
||||
.FirstAsync();
|
||||
if (item != null)
|
||||
{
|
||||
var removeItem = pagedList.List.LastOrDefault();
|
||||
pagedList.List.Remove(removeItem);
|
||||
@ -100,28 +103,39 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<UnifyPageResultDto<GetTrackTemplateContentPageOutputVO>> GetContentPageAsync(GetTrackTemplateContentPageInputVO input)
|
||||
public async Task<UnifyPageResultDto<GetTrackTemplateContentPageOutputVO>> GetContentPageAsync(
|
||||
GetTrackTemplateContentPageInputVO input)
|
||||
{
|
||||
return await Context.Queryable<TrackTemplateContentEntity>()
|
||||
.InnerJoin<TrackContentEntity>((templateContent, trackContent) => templateContent.TrackContentId == trackContent.Id && !trackContent.IsDeleted)
|
||||
.LeftJoin<TrackStatusEntity>((templateContent, trackContent, trackStatus) => trackContent.TrackStatusId == trackStatus.Id && !trackStatus.IsDeleted)
|
||||
.LeftJoin<VEnumValueInfoEntity>((templateContent, trackContent, trackStatus, enumValue) => enumValue.Property == EnumPropertyEnums.节点.GetDescription() && trackStatus.Node == enumValue.Enumkey && !enumValue.IsDeleted)
|
||||
.LeftJoin<TrackFlagEntity>((templateContent, trackContent, trackStatus, enumValue, trackFlag) => trackContent.TrackFlagId == trackFlag.Id && !trackFlag.IsDeleted)
|
||||
.LeftJoin<VUserEntity>((templateContent, trackContent, trackStatus, enumValue, trackFlag, createUser) => templateContent.CreateUserId == createUser.Id && !createUser.IsDeleted)
|
||||
.LeftJoin<VUserEntity>((templateContent, trackContent, trackStatus, enumValue, trackFlag, createUser, updateUser) => templateContent.UpdateUserId == updateUser.Id && !updateUser.IsDeleted)
|
||||
.InnerJoin<TrackContentEntity>((templateContent, trackContent) =>
|
||||
templateContent.TrackContentId == trackContent.Id && !trackContent.IsDeleted)
|
||||
.LeftJoin<TrackStatusEntity>((templateContent, trackContent, trackStatus) =>
|
||||
trackContent.TrackStatusId == trackStatus.Id && !trackStatus.IsDeleted)
|
||||
.LeftJoin<VEnumValueInfoEntity>((templateContent, trackContent, trackStatus, enumValue) =>
|
||||
enumValue.Property == EnumPropertyEnums.节点.GetDescription() && trackStatus.Node == enumValue.Enumkey &&
|
||||
!enumValue.IsDeleted)
|
||||
.LeftJoin<TrackFlagEntity>((templateContent, trackContent, trackStatus, enumValue, trackFlag) =>
|
||||
trackContent.TrackFlagId == trackFlag.Id && !trackFlag.IsDeleted)
|
||||
.LeftJoin<VUserEntity>((templateContent, trackContent, trackStatus, enumValue, trackFlag, createUser) =>
|
||||
templateContent.CreateUserId == createUser.Id && !createUser.IsDeleted)
|
||||
.LeftJoin<VUserEntity>(
|
||||
(templateContent, trackContent, trackStatus, enumValue, trackFlag, createUser, updateUser) =>
|
||||
templateContent.UpdateUserId == updateUser.Id && !updateUser.IsDeleted)
|
||||
.Filter(null, true)
|
||||
.Where(templateContent => templateContent.TrackTemplateId == input.TrackTemplateId && !templateContent.IsDeleted)
|
||||
.Select((templateContent, trackContent, trackStatus, enumValue, trackFlag, createUser, updateUser) => new GetTrackTemplateContentPageOutputVO
|
||||
{
|
||||
Id = templateContent.Id,
|
||||
TrackStatus = trackStatus.Status,
|
||||
Node = enumValue.Disp,
|
||||
TrackFlag = trackFlag.Name,
|
||||
CreateTime = templateContent.CreateTime,
|
||||
CreateUser = createUser.Name,
|
||||
UpdateTime = templateContent.UpdateTime,
|
||||
UpdateUser = updateUser.Name
|
||||
}, true)
|
||||
.Where(templateContent =>
|
||||
templateContent.TrackTemplateId == input.TrackTemplateId && !templateContent.IsDeleted)
|
||||
.Select((templateContent, trackContent, trackStatus, enumValue, trackFlag, createUser, updateUser) =>
|
||||
new GetTrackTemplateContentPageOutputVO
|
||||
{
|
||||
Id = templateContent.Id,
|
||||
TrackStatus = trackStatus.Status,
|
||||
Node = enumValue.Disp,
|
||||
TrackFlag = trackFlag.Name,
|
||||
CreateTime = templateContent.CreateTime,
|
||||
CreateUser = createUser.Name,
|
||||
UpdateTime = templateContent.UpdateTime,
|
||||
UpdateUser = updateUser.Name
|
||||
}, true)
|
||||
.ToPagedListAsync(input.PageIndex, input.PageSize);
|
||||
}
|
||||
|
||||
@ -129,8 +143,10 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
|
||||
public async Task<GetTrackTemplateContentDetailOutputVO> GetContentDetailAsync(int id)
|
||||
{
|
||||
return await Context.Queryable<TrackTemplateContentEntity>()
|
||||
.InnerJoin<TrackContentEntity>((templateContent, trackContent) => templateContent.TrackContentId == trackContent.Id && !trackContent.IsDeleted)
|
||||
.LeftJoin<TrackStatusEntity>((templateContent, trackContent, trackStatus) => trackContent.TrackStatusId == trackStatus.Id && !trackStatus.IsDeleted)
|
||||
.InnerJoin<TrackContentEntity>((templateContent, trackContent) =>
|
||||
templateContent.TrackContentId == trackContent.Id && !trackContent.IsDeleted)
|
||||
.LeftJoin<TrackStatusEntity>((templateContent, trackContent, trackStatus) =>
|
||||
trackContent.TrackStatusId == trackStatus.Id && !trackStatus.IsDeleted)
|
||||
.Filter(null, true)
|
||||
.Where(templateContent => templateContent.Id == id && !templateContent.IsDeleted)
|
||||
.Select((templateContent, trackContent, trackStatus) => new GetTrackTemplateContentDetailOutputVO
|
||||
|
||||
Loading…
Reference in New Issue
Block a user