后台:发送邮件
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { Controller } from 'egg';
|
||||
import { STATUS } from '@consts';
|
||||
|
||||
export default class MailController extends Controller {
|
||||
public async getGMMailList() {
|
||||
const { ctx } = this;
|
||||
const { page, pageSize, sortField, sortOrder, form } = ctx.request.body;
|
||||
ctx.body = await ctx.service.mail.getGMMailList(page, pageSize, sortField, sortOrder, form);
|
||||
return
|
||||
}
|
||||
|
||||
public async updateGMMail() {
|
||||
const { ctx } = this;
|
||||
const { _id, content, sendName, sendTime, endTime, useTempTime, continueHour } = 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);
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -72,4 +72,7 @@ export default (app: Application) => {
|
||||
router.post('/api/activity/deleteactivitygrouptype', controller.activity.deleteActivityGroupType);
|
||||
router.post('/api/activity/saveactivitygrouptype', controller.activity.saveGroupTypeToActivityGroup);
|
||||
router.post('/api/activity/getgroupdatabyid', controller.activity.getGroupDataById);
|
||||
|
||||
router.post('/api/mail/getgmmaillist', controller.mail.getGMMailList);
|
||||
router.post('/api/mail/updategmmail', controller.mail.updateGMMail);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
import { Service } from 'egg';
|
||||
import { GMMailModel } from '@db/GMMail';
|
||||
import { STATUS } from '@consts';
|
||||
|
||||
export default class Mail extends Service {
|
||||
|
||||
public async getGMMailList(page: number, pageSize: number, sortField: string, sortOrder: string, form: {}) {
|
||||
const { ctx } = this;
|
||||
const list = await GMMailModel.findByCondition(page, pageSize, sortField, sortOrder, form);
|
||||
const total = await GMMailModel.countByCondition( form )
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS, {
|
||||
list, total
|
||||
});
|
||||
}
|
||||
|
||||
public async updateGMMail(_id: string, content: string, sendName: string, useTempTime: boolean, sendTime: number, endTime: number, continueHour: number) {
|
||||
const { ctx } = this;
|
||||
if(_id == 'new') {
|
||||
await GMMailModel.addMail({ content, sendName, useTempTime, sendTime, endTime, continueHour });
|
||||
} else {
|
||||
await GMMailModel.updateMailById(_id, { content, sendName, useTempTime, sendTime, endTime, continueHour });
|
||||
}
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
}
|
||||
}
|
||||
+2
@@ -7,6 +7,7 @@ import ExportGame from '../../../app/controller/game';
|
||||
import ExportGmaccount from '../../../app/controller/gmaccount';
|
||||
import ExportHome from '../../../app/controller/home';
|
||||
import ExportLogin from '../../../app/controller/login';
|
||||
import ExportMail from '../../../app/controller/mail';
|
||||
import ExportUpload from '../../../app/controller/upload';
|
||||
import ExportUsers from '../../../app/controller/users';
|
||||
|
||||
@@ -17,6 +18,7 @@ declare module 'egg' {
|
||||
gmaccount: ExportGmaccount;
|
||||
home: ExportHome;
|
||||
login: ExportLogin;
|
||||
mail: ExportMail;
|
||||
upload: ExportUpload;
|
||||
users: ExportUsers;
|
||||
}
|
||||
|
||||
+2
@@ -9,6 +9,7 @@ type AutoInstanceType<T, U = T extends CanExportFunc ? T : T extends AnyFunc ? R
|
||||
import ExportActivity from '../../../app/service/Activity';
|
||||
import ExportGame from '../../../app/service/Game';
|
||||
import ExportGmUser from '../../../app/service/GmUser';
|
||||
import ExportMail from '../../../app/service/Mail';
|
||||
import ExportTest from '../../../app/service/Test';
|
||||
import ExportUtils from '../../../app/service/Utils';
|
||||
import ExportUsers from '../../../app/service/users';
|
||||
@@ -18,6 +19,7 @@ declare module 'egg' {
|
||||
activity: AutoInstanceType<typeof ExportActivity>;
|
||||
game: AutoInstanceType<typeof ExportGame>;
|
||||
gmUser: AutoInstanceType<typeof ExportGmUser>;
|
||||
mail: AutoInstanceType<typeof ExportMail>;
|
||||
test: AutoInstanceType<typeof ExportTest>;
|
||||
utils: AutoInstanceType<typeof ExportUtils>;
|
||||
users: AutoInstanceType<typeof ExportUsers>;
|
||||
|
||||
Reference in New Issue
Block a user