feat: 新增任务需求枚举
This commit is contained in:
@@ -7,7 +7,7 @@ public class AssignmentGetListInput
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 任务查询条件
|
/// 任务查询条件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public AssignmentQueryStateEnum? AssignmentQueryState { get; set; }
|
public AssignmentQueryStateEnum AssignmentQueryState { get; set; } = AssignmentQueryStateEnum.Progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum AssignmentQueryStateEnum
|
public enum AssignmentQueryStateEnum
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
namespace Yi.Framework.Bbs.Domain.Shared.Enums;
|
||||||
|
|
||||||
|
public enum AssignmentRequirementTypeEnum
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 主题
|
||||||
|
/// </summary>
|
||||||
|
Discuss=2,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 评论
|
||||||
|
/// </summary>
|
||||||
|
Comment=4,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新个人中心
|
||||||
|
/// </summary>
|
||||||
|
UpdateProfile=8,
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 点赞
|
||||||
|
/// </summary>
|
||||||
|
Agree=16
|
||||||
|
|
||||||
|
}
|
||||||
@@ -52,9 +52,9 @@ public class AssignmentAggregateRoot : AggregateRoot<Guid>, IHasCreationTime, IO
|
|||||||
public DateTime? CompleteTime { get; set; }
|
public DateTime? CompleteTime { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public DateTime CreationTime { get; }
|
public DateTime CreationTime { get; set; }
|
||||||
public int OrderNum { get; set; }
|
public int OrderNum { get; set; }
|
||||||
public DateTime? LastModificationTime { get; }
|
public DateTime? LastModificationTime{ get; set; }
|
||||||
|
|
||||||
|
|
||||||
public bool IsAllowCompleted()
|
public bool IsAllowCompleted()
|
||||||
@@ -72,4 +72,11 @@ public class AssignmentAggregateRoot : AggregateRoot<Guid>, IHasCreationTime, IO
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetComplete()
|
||||||
|
{
|
||||||
|
this.AssignmentState = AssignmentStateEnum.Completed;
|
||||||
|
this.CompleteTime=DateTime.Now;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -31,6 +31,11 @@ public class AssignmentDefineAggregateRoot: AggregateRoot<Guid>, IHasCreationTim
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public AssignmentTypeEnum AssignmentType{ get; set; }
|
public AssignmentTypeEnum AssignmentType{ get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 任务需求类型
|
||||||
|
/// </summary>
|
||||||
|
public AssignmentRequirementTypeEnum AssignmentRequirementType{ get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 总共步骤数
|
/// 总共步骤数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -46,6 +51,6 @@ public class AssignmentDefineAggregateRoot: AggregateRoot<Guid>, IHasCreationTim
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public decimal RewardsMoneyNumber { get; set; }
|
public decimal RewardsMoneyNumber { get; set; }
|
||||||
|
|
||||||
public DateTime CreationTime { get; }
|
public DateTime CreationTime{ get; set; }
|
||||||
public int OrderNum { get; set; }
|
public int OrderNum { get; set; }
|
||||||
}
|
}
|
||||||
@@ -68,11 +68,18 @@ public class AssignmentManager : DomainService
|
|||||||
var assignment = await _assignmentRepository.GetByIdAsync(asignmentId);
|
var assignment = await _assignmentRepository.GetByIdAsync(asignmentId);
|
||||||
if (assignment.IsAllowCompleted())
|
if (assignment.IsAllowCompleted())
|
||||||
{
|
{
|
||||||
//设置已完成,并领取奖励,钱钱
|
|
||||||
assignment.AssignmentState = AssignmentStateEnum.Completed;
|
|
||||||
//加钱加钱
|
//加钱加钱
|
||||||
await _localEventBus.PublishAsync(
|
await _localEventBus.PublishAsync(
|
||||||
new MoneyChangeEventArgs { UserId = assignment.UserId, Number = assignment.RewardsMoneyNumber }, false);
|
new MoneyChangeEventArgs { UserId = assignment.UserId, Number = assignment.RewardsMoneyNumber }, false);
|
||||||
|
|
||||||
|
//设置已完成,并领取奖励,钱钱
|
||||||
|
assignment.SetComplete();
|
||||||
|
await _assignmentRepository.UpdateAsync(assignment);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//不能领取
|
||||||
|
throw new UserFriendlyException("该任务无法领取奖励,请检查任务详情");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,61 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import {getCanReceiveAssignment} from '@/apis/assignmentApi'
|
import {getAssignmentList, getCanReceiveAssignment, acceptAssignment, receiveAssignment} from '@/apis/assignmentApi'
|
||||||
import {onMounted, ref} from "vue";
|
import {onMounted, reactive, ref} from "vue";
|
||||||
|
|
||||||
const canReceiveAssignmentList=ref([]);
|
const canReceiveAssignmentList=ref([]);
|
||||||
|
|
||||||
|
const assignmentList=ref([]);
|
||||||
|
const queryForm=reactive({
|
||||||
|
assignmentQueryState:"Progress"
|
||||||
|
});
|
||||||
|
|
||||||
onMounted( async ()=>{
|
onMounted( async ()=>{
|
||||||
|
await refreshData();
|
||||||
|
});
|
||||||
|
//刷新数据
|
||||||
|
const refreshData=async ()=>{
|
||||||
|
|
||||||
const {data:canReceiveAssignmentListData}= await getCanReceiveAssignment();
|
const {data:canReceiveAssignmentListData}= await getCanReceiveAssignment();
|
||||||
canReceiveAssignmentList.value=canReceiveAssignmentListData;
|
canReceiveAssignmentList.value=canReceiveAssignmentListData;
|
||||||
|
|
||||||
});
|
const {data}= await getAssignmentList(queryForm);
|
||||||
|
assignmentList.value=data;
|
||||||
|
}
|
||||||
|
|
||||||
|
//接收任务
|
||||||
|
const onClickAcceptAssignment=async (id)=>{
|
||||||
|
await acceptAssignment(id);
|
||||||
|
await refreshData();
|
||||||
|
}
|
||||||
|
|
||||||
|
const onClickReceiveAssignment=async (id)=>{
|
||||||
|
await receiveAssignment(id);
|
||||||
|
await refreshData();
|
||||||
|
}
|
||||||
|
|
||||||
|
//切换tab
|
||||||
|
const changeTab=async (state)=>{
|
||||||
|
queryForm.assignmentQueryState=state;
|
||||||
|
await refreshData();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
||||||
|
<h3>可接收任务</h3>
|
||||||
<div>
|
<div>
|
||||||
<div v-for="item in canReceiveAssignmentList">{{item}}</div>
|
<div v-for="item in canReceiveAssignmentList">{{item}}
|
||||||
|
<button type="button" @click="onClickAcceptAssignment(item.id)">接收任务</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
<h3>已接收任务
|
||||||
|
<button type="button" @click="changeTab('Progress')">切换正在进行</button>
|
||||||
|
<button type="button" @click="changeTab('End')">切换已结束</button></h3>
|
||||||
|
<div>
|
||||||
|
<div v-for="item in assignmentList">{{item}}
|
||||||
|
<button type="button" @click="onClickReceiveAssignment(item.id)">领取奖励</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
Reference in New Issue
Block a user