军团:权限判断函数提取
This commit is contained in:
@@ -8,11 +8,12 @@ import { getArmyWishPoolBaseByLv, getGoodById } from '../../../pubUtils/data';
|
||||
import { addItems, checkGoods } from '../../../services/rewardService';
|
||||
import { IT_TYPE } from '../../../consts/constModules/itemConst';
|
||||
import { GUILD_STRUCTURE } from '../../../consts/constModules/guildConst';
|
||||
import { getUserGuildWithRefActive, getWishPool } from '../../../services/guildService';
|
||||
import { refreshUserGuild, getWishPool, getUserGuildWithRefActive } from '../../../services/guildService';
|
||||
import { findIndex, findWhere } from 'underscore';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { getRoleOnlineInfo } from '../../../services/redisService';
|
||||
import { ARMY } from '../../../pubUtils/dicParam';
|
||||
import { guildInter } from '../../../pubUtils/interface';
|
||||
export default function(app: Application) {
|
||||
return new WishPoolHandler(app);
|
||||
}
|
||||
@@ -22,9 +23,10 @@ export class WishPoolHandler {
|
||||
|
||||
}
|
||||
|
||||
async getWishPool(msg: {}, session: BackendSession) {
|
||||
async getWishPool(msg: guildInter & {}, session: BackendSession) {
|
||||
const roleId: string = session.get('roleId');
|
||||
let userGuild = await getUserGuildWithRefActive(roleId, 'wishDntCnt wishGoods guildCode');
|
||||
const { myUserGuild } = msg;
|
||||
let userGuild = await refreshUserGuild(myUserGuild, roleId);
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
let res = await getWishPool(userGuild);
|
||||
@@ -32,8 +34,8 @@ export class WishPoolHandler {
|
||||
}
|
||||
|
||||
// 许愿
|
||||
async wishGoods(msg: {goodId: number, type: number}, session: BackendSession) {
|
||||
const { goodId, type } = msg;
|
||||
async wishGoods(msg: guildInter & {goodId: number, type: number}, session: BackendSession) {
|
||||
const { goodId, type, myUserGuild } = msg;
|
||||
const roleId: string = session.get('roleId');
|
||||
const serverId: number = parseInt(session.get('serverId'));
|
||||
let count;
|
||||
@@ -42,7 +44,7 @@ export class WishPoolHandler {
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
if (!(goodInfo.itid == IT_TYPE.HERO_PIECE && type == 2 ) && !(goodInfo.itid == IT_TYPE.EQUIP_PIECE && type == 1 ))
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
let userGuild = await getUserGuildWithRefActive(roleId, ' wishDntCnt wishGoods guildCode wishGoods');
|
||||
let userGuild = await refreshUserGuild(myUserGuild, roleId);
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
let result = await checkGoods(roleId, [goodId]);
|
||||
@@ -85,8 +87,8 @@ export class WishPoolHandler {
|
||||
}
|
||||
|
||||
// 捐赠
|
||||
async donateGoods(msg: {wishRoleId: string, id: string}, session: BackendSession) {
|
||||
let { wishRoleId, id } = msg;
|
||||
async donateGoods(msg: guildInter & {wishRoleId: string, id: string}, session: BackendSession) {
|
||||
let { wishRoleId, id, myUserGuild } = msg;
|
||||
const dntRoleId: string = session.get('roleId');
|
||||
const dntRoleName: string = session.get('roleName');
|
||||
if (wishRoleId == dntRoleId)
|
||||
@@ -98,7 +100,7 @@ export class WishPoolHandler {
|
||||
if (!wishUserGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const { guildCode: code, wishGoods } = wishUserGuild;
|
||||
let dntRoleGuild = await getUserGuildWithRefActive(dntRoleId, ' wishDntCnt wishGoods guildCode');
|
||||
let dntRoleGuild = await refreshUserGuild(myUserGuild, dntRoleId);
|
||||
if (!dntRoleGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
if (dntRoleGuild.guildCode != code)
|
||||
@@ -125,12 +127,12 @@ export class WishPoolHandler {
|
||||
});
|
||||
}
|
||||
|
||||
async receiveGoods(msg: { id: string }, session: BackendSession) {
|
||||
let { id } = msg;
|
||||
async receiveGoods(msg: guildInter & { id: string }, session: BackendSession) {
|
||||
let { id, myUserGuild } = msg;
|
||||
const roleId: string = session.get('roleId');
|
||||
const roleName: string = session.get('roleName');
|
||||
const sid: string = session.get('sid');
|
||||
let userGuild = await getUserGuildWithRefActive(roleId, 'wishDntCnt wishGoods guildCode');
|
||||
let userGuild = await refreshUserGuild(myUserGuild, roleId);
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const { wishGoods } = userGuild;
|
||||
@@ -148,9 +150,10 @@ export class WishPoolHandler {
|
||||
return resResult(STATUS.SUCCESS, { goods, wishGoods });
|
||||
}
|
||||
|
||||
async getReports(msg: {}, session: BackendSession) {
|
||||
async getReports(msg: guildInter & {}, session: BackendSession) {
|
||||
const roleId: string = session.get('roleId');
|
||||
let userGuild = await getUserGuildWithRefActive(roleId, ' guildCode');
|
||||
const { myUserGuild } = msg;
|
||||
let userGuild = await refreshUserGuild(myUserGuild, roleId);
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const { guildCode: code } = userGuild;
|
||||
|
||||
Reference in New Issue
Block a user