后台:任务对应活动
This commit is contained in:
@@ -6,6 +6,8 @@ import { ServerlistModel } from '@db/Serverlist';
|
||||
import { GMUserType } from '@db/GMUser';
|
||||
import { SignInData } from '@domain/activityField/signInField';
|
||||
import { ActivityGroupTypeModel } from '@db/ActivityGroupType';
|
||||
import { ActivityTaskPointModel } from '@db/ActivityTaskPoint';
|
||||
import { gameData } from '@pubUtils/data';
|
||||
|
||||
/**
|
||||
* Test Service
|
||||
@@ -38,7 +40,7 @@ export default class Activity extends Service {
|
||||
|
||||
if(activity.type == ACTIVITY_TYPE.SIGN_IN || activity.type == ACTIVITY_TYPE.SIGN_IN_VIP) {
|
||||
// 签到活动的不显示期内也可以编辑
|
||||
let signInObj = new SignInData(activity);
|
||||
let signInObj = new SignInData(activity, 0);
|
||||
if(signInObj.beginTime < now.getTime() && signInObj.endTime > now.getTime() ) {
|
||||
return this.ctx.service.utils.resResult(STATUS.GM_CAN_NOT_EDIT_ACT);
|
||||
}
|
||||
@@ -296,5 +298,38 @@ export default class Activity extends Service {
|
||||
data: { groupId, groupType: type, activities }
|
||||
});
|
||||
}
|
||||
|
||||
public async getActivityTaskPoint(page: number, pageSize: number, sortField: string, sortOrder: string, form: {taskType?: number, taskId?: number, activityId?: number}) {
|
||||
const { ctx } = this;
|
||||
const list = await ActivityTaskPointModel.findByCondition(page, pageSize, sortField, sortOrder, form);
|
||||
const total = await ActivityTaskPointModel.countByCondition(form);
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS, {
|
||||
list, total
|
||||
});
|
||||
}
|
||||
|
||||
public async createTaskToActivity(taskType: number, activityId: number) {
|
||||
const { ctx } = this;
|
||||
let dicTask = gameData.tasks.get(taskType);
|
||||
if(!dicTask) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
for(let [id, dic] of dicTask) {
|
||||
await ActivityTaskPointModel.createDataIfNotExist(taskType, id, activityId, dic['point']||0, ctx.user?.uid);
|
||||
}
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
public async updateActivityTaskPoint(taskType: number, taskId: number, activityId: number, point: number) {
|
||||
const { ctx } = this;
|
||||
let result = await ActivityTaskPointModel.updateData(taskType, taskId, activityId, point, ctx.user?.uid);
|
||||
if(!result) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
public async delActivityTaskPoint(taskType: number, taskId: number, activityId: number) {
|
||||
const { ctx } = this;
|
||||
|
||||
await ActivityTaskPointModel.deleteData(taskType, taskId, activityId);
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user