后台:获取邮件记录

This commit is contained in:
luying
2021-06-30 14:05:34 +08:00
parent 730aeae370
commit 0d12af8ac6
6 changed files with 152 additions and 5 deletions

View File

@@ -11,14 +11,27 @@ export default class MailController extends Controller {
public async updateGMMail() {
const { ctx } = this;
const { _id, content, sendName, sendTime, endTime, useTempTime, continueHour } = ctx.request.body;
const { _id, content, sendName, sendTime, endTime, useTempTime, continueHour, goods } = ctx.request.body;
if(!_id) return ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS);
if(useTempTime) {
if(!sendTime || !endTime) return ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS);
} else {
if(!continueHour) return ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS);
}
ctx.body = await ctx.service.mail.updateGMMail(_id, content, sendName, useTempTime, sendTime, endTime, continueHour);
let updateGoods = [];
try{
updateGoods = JSON.parse(goods);
} catch(e) {
return ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS);
}
ctx.body = await ctx.service.mail.updateGMMail(_id, content, sendName, useTempTime, sendTime, endTime, continueHour, updateGoods);
return
}
public async getGMMailRecords() {
const { ctx } = this;
const { page, pageSize, sortField, sortOrder, form } = ctx.request.body;
ctx.body = await ctx.service.mail.getGMMailRecords(page, pageSize, sortField, sortOrder, form);
return
}
}

View File

@@ -75,4 +75,5 @@ export default (app: Application) => {
router.post('/api/mail/getgmmaillist', controller.mail.getGMMailList);
router.post('/api/mail/updategmmail', controller.mail.updateGMMail);
router.post('/api/mail/getgmmailrecords', controller.mail.getGMMailRecords);
};

View File

@@ -2,6 +2,8 @@
import { Service } from 'egg';
import { GMMailModel } from '@db/GMMail';
import { STATUS } from '@consts';
import { GMMailRecordModel } from '@db/GMMailRecord';
import { RewardInter } from '@pubUtils/interface';
export default class Mail extends Service {
@@ -14,13 +16,21 @@ export default class Mail extends Service {
});
}
public async updateGMMail(_id: string, content: string, sendName: string, useTempTime: boolean, sendTime: number, endTime: number, continueHour: number) {
public async updateGMMail(_id: string, content: string, sendName: string, useTempTime: boolean, sendTime: number, endTime: number, continueHour: number, goods: RewardInter[]) {
const { ctx } = this;
if(_id == 'new') {
await GMMailModel.addMail({ content, sendName, useTempTime, sendTime, endTime, continueHour });
await GMMailModel.addMail({ content, sendName, useTempTime, sendTime, endTime, continueHour, goods });
} else {
await GMMailModel.updateMailById(_id, { content, sendName, useTempTime, sendTime, endTime, continueHour });
await GMMailModel.updateMailById(_id, { content, sendName, useTempTime, sendTime, endTime, continueHour, goods });
}
return ctx.service.utils.resResult(STATUS.SUCCESS);
}
public async getGMMailRecords(page: number, pageSize: number, sortField: string, sortOrder: string, form: {}) {
const { ctx } = this;
const list = await GMMailRecordModel.findByCondition(page, pageSize, sortField, sortOrder, form);
return ctx.service.utils.resResult(STATUS.SUCCESS, {
list
});
}
}