增加服务端获取卡组信息的接口
This commit is contained in:
parent
ceb0b8f4a2
commit
2099384e46
@ -1,10 +1,11 @@
|
||||
import BaseController from "../common/base.controller";
|
||||
import {router} from "../decorators/router";
|
||||
import {role, router} from "../decorators/router";
|
||||
import {CardGroup} from "../models/CardGroup";
|
||||
import {ZError} from "../common/ZError";
|
||||
import {Card} from "../models/subdoc/Card";
|
||||
import {MoneyTypeConst} from "../constants/MoneyTypeConst";
|
||||
import {BaseConst} from "../constants/BaseConst";
|
||||
import {User} from "../models/User";
|
||||
|
||||
export default class CardController extends BaseController {
|
||||
@router('post /api/:accountid/card_group/:heroid')
|
||||
@ -23,6 +24,28 @@ export default class CardController extends BaseController {
|
||||
return result;
|
||||
}
|
||||
|
||||
@role('svr')
|
||||
@router('get /api/:accountid/group_info/:heroid/:gid')
|
||||
async cardGroupInfo(req: any) {
|
||||
let {accountid, heroid, gid} = req.params;
|
||||
let record;
|
||||
if (gid) {
|
||||
record = await CardGroup.findById(gid);
|
||||
}
|
||||
if (!record) {
|
||||
if (!heroid || !accountid) {
|
||||
throw new ZError(101, 'not enough params');
|
||||
}
|
||||
heroid = parseInt(heroid);
|
||||
record = await CardGroup.findOne({accountid, heroid, deleted: false, isdefault: true});
|
||||
}
|
||||
if (!record) {
|
||||
throw new ZError(103, 'no card group found');
|
||||
}
|
||||
return record.toJson();
|
||||
}
|
||||
|
||||
|
||||
@router('post /api/:accountid/card_group/save/:gid')
|
||||
async saveCardGroup(req: any) {
|
||||
let {accountid, gid, heroid, selected, cards} = req.params;
|
||||
|
@ -28,6 +28,10 @@ const apiAuthPlugin: FastifyPluginAsync = async function(
|
||||
fastify.decorate("apiAuth", async function(request: FastifyRequest, reply: FastifyReply) {
|
||||
if (!request.roles || request.roles.indexOf('anon') == -1) {
|
||||
try {
|
||||
if (request.roles.indexOf('svr') >= 0) {
|
||||
// TODO: check svr
|
||||
return;
|
||||
}
|
||||
// @ts-ignore
|
||||
let { accountid, sessionid } = request.params;
|
||||
//TODO: 增加sessionid的校验
|
||||
|
Loading…
x
Reference in New Issue
Block a user