feat: 新增任务接口路由
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Volo.Abp.Application.Services;
|
||||
using Volo.Abp.Users;
|
||||
using Yi.Framework.Bbs.Application.Contracts.Dtos.Assignment;
|
||||
using Yi.Framework.Bbs.Domain.Managers;
|
||||
using Yi.Framework.Bbs.Domain.Shared.Enums;
|
||||
|
||||
namespace Yi.Framework.Bbs.Application.Services;
|
||||
|
||||
@@ -26,26 +27,49 @@ public class AssignmentService : ApplicationService
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
[HttpPost("assignment/accept/{id}")]
|
||||
public async Task AcceptAsync(Guid id)
|
||||
public async Task AcceptAsync([FromRoute]Guid id)
|
||||
{
|
||||
await _assignmentManager.AcceptAsync(CurrentUser.GetId(), id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 接收任务奖励
|
||||
/// 领取任务奖励
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
[HttpPost("assignment/receive-rewards/{id}")]
|
||||
public async Task ReceiveRewardsAsync(Guid id)
|
||||
[HttpPost("assignment/complete/{id}")]
|
||||
public async Task ReceiveRewardsAsync([FromRoute]Guid id)
|
||||
{
|
||||
await _assignmentManager.ReceiveRewardsAsync(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询任务
|
||||
/// 查看可接受的任务
|
||||
/// </summary>
|
||||
public async Task<PagedResultDto<AssignmentGetListOutputDto>> GetListAsync(AssignmentGetListInput input)
|
||||
/// <returns></returns>
|
||||
[HttpGet("assignment/receive")]
|
||||
public async Task<List<AssignmentDefineGetListOutputDto>> GetCanReceiveListAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var entities = await _assignmentManager.GetCanReceiveListAsync(CurrentUser.GetId());
|
||||
var output = entities.Adapt<List<AssignmentDefineGetListOutputDto>>();
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询接受的任务
|
||||
/// </summary>
|
||||
[HttpGet("assignment")]
|
||||
public async Task<List<AssignmentGetListOutputDto>> GetListAsync([FromQuery]AssignmentGetListInput input)
|
||||
{
|
||||
var entities= await _assignmentManager._assignmentRepository._DbQueryable
|
||||
.Where(x => x.UserId == CurrentUser.GetId())
|
||||
.WhereIF(input.AssignmentQueryState == AssignmentQueryStateEnum.Progress,
|
||||
x => x.AssignmentState == AssignmentStateEnum.Progress)
|
||||
.WhereIF(input.AssignmentQueryState == AssignmentQueryStateEnum.End,
|
||||
x => x.AssignmentState == AssignmentStateEnum.Completed ||
|
||||
x.AssignmentState == AssignmentStateEnum.Expired)
|
||||
.ToListAsync();
|
||||
|
||||
var output= entities.Adapt<List<AssignmentGetListOutputDto>>();
|
||||
return output;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user