后台:权限

This commit is contained in:
luying
2021-12-21 10:08:24 +08:00
parent 151ac33b91
commit 7d0808a9dc
26 changed files with 1009 additions and 818 deletions

View File

@@ -2,8 +2,8 @@ import { GMUserModel } from '@db/GMUser';
import { GMUserGroupModel } from '@db/GMUserGroup'
import { GMGroupModel } from '@db/GMGroup'
import { GMRecordModel } from '@db/GMRecord'
import { ApiModel } from '@db/Api';
import { STATUS } from '@consts';
import { gameData } from 'app/pubUtils/data';
module.exports = () => {
return async function tokenParser(ctx, next) {
@@ -20,18 +20,18 @@ module.exports = () => {
return;
}
const url = ctx.request.url;
let apiResult = await ApiModel.getApi(url);
if(!apiResult) {
let dicApi = gameData.apiByUrl.get(url);
if(!dicApi) {
ctx.body = ctx.service.utils.resResult(STATUS.GM_MISS_API);
return;
}
let userGroups = await GMUserGroupModel.getUserGroupByUid(user.uid, 1);
let userGroups = await GMUserGroupModel.getUserGroupByUid(user.uid, ctx.app.config.realEnv);
let flag = 0;
for(let userGroup of userGroups) {
let { groupId } = userGroup;
let group = await GMGroupModel.getGroupById(groupId);
if(group) {
if(group.apis.includes(apiResult.apiId)) {
if(group.apis.includes(dicApi.id)) {
flag = 1; break;
}
}