feat: 完成dto搭建

This commit is contained in:
ccnetcore
2025-06-21 13:20:13 +08:00
parent 25c88187a3
commit 1d16502d32
3 changed files with 17 additions and 9 deletions

View File

@@ -1,8 +1,7 @@
namespace Yi.Framework.AiHub.Application.Contracts.Dtos; namespace Yi.Framework.AiHub.Application.Contracts.Dtos;
public class SessionInputDto public class SessionCreateAndUpdateInput
{ {
public Guid UserId { get; set; }
public string SessionTitle { get; set; } public string SessionTitle { get; set; }
public string SessionContent { get; set; } public string SessionContent { get; set; }
public string Remark { get; set; } public string Remark { get; set; }

View File

@@ -1,6 +1,8 @@
namespace Yi.Framework.AiHub.Application.Contracts.Dtos; using Yi.Framework.Ddd.Application.Contracts;
public class SessionGetListInput namespace Yi.Framework.AiHub.Application.Contracts.Dtos;
public class SessionGetListInput:PagedAllResultRequestDto
{ {
public string? SessionTitle { get; set; } public string? SessionTitle { get; set; }
} }

View File

@@ -1,6 +1,7 @@
using Mapster; using Mapster;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
@@ -11,7 +12,7 @@ using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Framework.AiHub.Application.Services; namespace Yi.Framework.AiHub.Application.Services;
public class SessionService : CrudAppService<SessionAggregateRoot, SessionDto, Guid, SessionGetListInput> public class SessionService : CrudAppService<SessionAggregateRoot, SessionDto, Guid,SessionGetListInput,SessionCreateAndUpdateInput>
{ {
private readonly ISqlSugarRepository<SessionAggregateRoot, Guid> _repository; private readonly ISqlSugarRepository<SessionAggregateRoot, Guid> _repository;
public readonly ISqlSugarRepository<MessageAggregateRoot, Guid> _messageRepository; public readonly ISqlSugarRepository<MessageAggregateRoot, Guid> _messageRepository;
@@ -27,7 +28,7 @@ public class SessionService : CrudAppService<SessionAggregateRoot, SessionDto, G
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
[Authorize] [Authorize]
public override async Task<SessionDto> CreateAsync(SessionDto input) public override async Task<SessionDto> CreateAsync(SessionCreateAndUpdateInput input)
{ {
var entity = await MapToEntityAsync(input); var entity = await MapToEntityAsync(input);
entity.UserId = CurrentUser.GetId(); entity.UserId = CurrentUser.GetId();
@@ -53,7 +54,7 @@ public class SessionService : CrudAppService<SessionAggregateRoot, SessionDto, G
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
[Authorize] [Authorize]
public override Task<SessionDto> UpdateAsync(Guid id, SessionDto input) public override Task<SessionDto> UpdateAsync(Guid id, SessionCreateAndUpdateInput input)
{ {
return base.UpdateAsync(id, input); return base.UpdateAsync(id, input);
} }
@@ -77,8 +78,14 @@ public class SessionService : CrudAppService<SessionAggregateRoot, SessionDto, G
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
[Authorize] [Authorize]
public override Task<PagedResultDto<SessionDto>> GetListAsync(SessionGetListInput input) public override async Task<PagedResultDto<SessionDto>> GetListAsync(SessionGetListInput input)
{ {
return base.GetListAsync(input); RefAsync<int> total = 0;
var userId = CurrentUser.GetId();
var entities = await _repository._DbQueryable
.Where(x=>x.UserId == userId)
.OrderByDescending(x => x.Id)
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
return new PagedResultDto<SessionDto>(total, entities.Adapt<List<SessionDto>>());
} }
} }