后台:邮件
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Controller } from 'egg';
|
||||
import { GM_MAIL_STATUS, GM_MAIL_TYPE, STATUS } from '@consts';
|
||||
import { UpdateMailParams } from '@domain/backEndField/params';
|
||||
|
||||
export default class MailController extends Controller {
|
||||
|
||||
@@ -58,22 +59,25 @@ export default class MailController extends Controller {
|
||||
return
|
||||
}
|
||||
|
||||
public async findRoleByIdOrName() {
|
||||
const { ctx } = this;
|
||||
const { serverId, roleId, roleName }: { serverId: number, roleId?: string, roleName?: string } = ctx.request.body;
|
||||
if(!serverId || (!roleId && !roleName)) return ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
ctx.body = await ctx.service.mail.findRoleByIdOrName(serverId, roleId, roleName);
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
public async updateGMMail() {
|
||||
const { ctx } = this;
|
||||
const { _id, 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);
|
||||
const msg = ctx.request.body;
|
||||
if(msg._id == 'new') {
|
||||
let params = new UpdateMailParams(msg);
|
||||
let check = params.checkParams();
|
||||
if(!check) return ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
ctx.body = await ctx.service.mail.createGmMail(params);
|
||||
}
|
||||
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, updateGoods);
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -103,6 +103,7 @@ export default (app: Application) => {
|
||||
router.post('/api/mail/getviewsinglemailtxt', controller.mail.getViewSingleMailTxt);
|
||||
router.post('/api/mail/getviewservermail', controller.mail.getViewServerMail);
|
||||
router.post('/api/mail/getviewservermailtxt', controller.mail.getViewServerMailTxt);
|
||||
router.post('/api/mail/findrolebyidorname', controller.mail.findRoleByIdOrName);
|
||||
router.post('/api/mail/updategmmail', controller.mail.updateGMMail);
|
||||
router.post('/api/mail/getgmmailrecords', controller.mail.getGMMailRecords);
|
||||
};
|
||||
|
||||
@@ -90,8 +90,8 @@ export default class Game extends Service {
|
||||
|
||||
let marqueeResult = await MarqueeModel.createData({ ...marquee, serverIds: values.serverIds, type: MARQUEE_TYPE.SCHEDULE, isRunning: false }, ctx.user?.uid);
|
||||
let noticeResult = await NoticeModel.updateNotice('new', { ...notice, type: 1, sort: 1000, serverType: curEnv?.serverType, isEnable: false }, ctx.user?.uid);
|
||||
let mailResult = await GMMailModel.addMail({ ...mail, }, ctx.user?.uid);
|
||||
await MaintenanceModel.createData(values, marqueeResult, noticeResult, mailResult);
|
||||
// let mailResult = await GMMailModel.addMail(mail, ctx.user?.uid);
|
||||
await MaintenanceModel.createData(values, marqueeResult, noticeResult, null);
|
||||
} else {
|
||||
let maintenanceResult = await MaintenanceModel.updateData(values.code, values, ctx.user?.uid);
|
||||
if(!maintenanceResult) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
|
||||
import { Service } from 'egg';
|
||||
import { GMMailModel } from '@db/GMMail';
|
||||
import { GMMailModel, } from '@db/GMMail';
|
||||
import { STATUS } from '@consts';
|
||||
import { GMMailRecordModel } from '@db/GMMailRecord';
|
||||
import { RewardInter } from '@pubUtils/interface';
|
||||
import { SearchMailParam } from '@domain/backEndField/search';
|
||||
import { UpdateMailParams } from '@domain/backEndField/params';
|
||||
import { RoleModel, RoleType } from '@db/Role';
|
||||
|
||||
export default class Mail extends Service {
|
||||
|
||||
@@ -17,12 +18,32 @@ export default class Mail extends Service {
|
||||
});
|
||||
}
|
||||
|
||||
public async updateGMMail(_id: string, goods: RewardInter[]) {
|
||||
public async findRoleByIdOrName(serverId: number, roleId: string, roleName: string) {
|
||||
let role: RoleType;
|
||||
if(roleId) {
|
||||
role = await RoleModel.findByRoleId(roleId);
|
||||
}
|
||||
if(roleName) {
|
||||
role = await RoleModel.findByRoleName(roleName);
|
||||
}
|
||||
if(!role || role.serverId != serverId) return this.ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
return this.ctx.service.utils.resResult(STATUS.SUCCESS, { env: this.ctx.app.config.realEnv, serverId, roleId: role.roleId, roleName: role.roleName })
|
||||
|
||||
}
|
||||
|
||||
public async createGmMail(params: UpdateMailParams) {
|
||||
const { ctx } = this;
|
||||
if(_id == 'new') {
|
||||
await GMMailModel.addMail({ goods });
|
||||
await GMMailModel.addMail(params);
|
||||
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
public async updateGMMail(isCreate: boolean, params: UpdateMailParams) {
|
||||
const { ctx } = this;
|
||||
if(isCreate) {
|
||||
await GMMailModel.addMail(params);
|
||||
} else {
|
||||
await GMMailModel.updateMailById(_id, { goods });
|
||||
// await GMMailModel.updateMailById(params._id, params);
|
||||
}
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user