活动:任务接口添加serverId接口
This commit is contained in:
@@ -16,32 +16,34 @@ export default class Activity extends Service {
|
||||
const list = await ActivityModel.findByCondition(page, pageSize, type, serverId, current, activityId);
|
||||
const total = await ActivityModel.countByCondition(type, serverId, current, activityId);
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS, {
|
||||
list: list.map(cur => { return {
|
||||
...cur, beginTime: cur.beginTime.getTime(), endTime: cur.endTime.getTime()
|
||||
} }), total
|
||||
list: list.map(cur => {
|
||||
return {
|
||||
...cur, beginTime: cur.beginTime.getTime(), endTime: cur.endTime.getTime()
|
||||
}
|
||||
}), total
|
||||
});
|
||||
}
|
||||
|
||||
public async updateActivity(activityId: number|string, serverId: number, beginTime: number, endTime: number, type: number, data: string) {
|
||||
public async updateActivity(activityId: number | string, serverId: number, beginTime: number, endTime: number, type: number, data: string) {
|
||||
const { ctx } = this;
|
||||
if(!type || !data) {
|
||||
if (!type || !data) {
|
||||
return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
}
|
||||
try {
|
||||
let result = JSON.parse(data);
|
||||
ctx.service.utils.checkActivityData(result, type);
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
}
|
||||
let aids: number[] = [];
|
||||
if(typeof activityId == 'number') {
|
||||
if (typeof activityId == 'number') {
|
||||
aids.push(activityId);
|
||||
} else {
|
||||
activityId.split(',').forEach(aidStr => {
|
||||
aids.push(parseInt(aidStr));
|
||||
});
|
||||
}
|
||||
const activity = await ActivityModel.addActivity(aids, serverId, beginTime?new Date(beginTime): undefined, endTime?new Date(endTime): undefined, type, data);
|
||||
const activity = await ActivityModel.addActivity(aids, serverId, beginTime ? new Date(beginTime) : undefined, endTime ? new Date(endTime) : undefined, type, data);
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS, {
|
||||
activity
|
||||
})
|
||||
@@ -50,7 +52,7 @@ export default class Activity extends Service {
|
||||
public async deleteActivity(activityId: number) {
|
||||
const { ctx } = this;
|
||||
const result = await ActivityModel.deleteActivity(activityId);
|
||||
if(result) {
|
||||
if (result) {
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
} else {
|
||||
return ctx.service.utils.resResult(STATUS.ACTIVITY_MISSING);
|
||||
|
||||
Reference in New Issue
Block a user